aboutsummaryrefslogtreecommitdiff
path: root/lib/websocket/opcode.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2019-03-10 18:44:35 +0700
committerShulhan <ms@kilabit.info>2019-03-10 18:44:35 +0700
commit2a3bd1898256bfa878485f2d61a193057499f656 (patch)
tree905d3fedaeaf12dc82e8a1d513e92ae2219db625 /lib/websocket/opcode.go
parent397ef30e6533299d1d3ff8a8bc33077be5dd1c9f (diff)
downloadpakakeh.go-2a3bd1898256bfa878485f2d61a193057499f656.tar.xz
websocket: add server handler for reserved control frame
The handler is called HandlerRsvControl that can be set before running the server. Default HandlerRsvControl is nil. Since the handler expect Frame as parameter, we need to adjust and add two methods to access Frame's internal fields and methods; which is exporting NewFrame function and Frame.Pack method, and adding method Opcode() and Payload() to access Frame's opcode and payload.
Diffstat (limited to 'lib/websocket/opcode.go')
-rw-r--r--lib/websocket/opcode.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/websocket/opcode.go b/lib/websocket/opcode.go
index a0872338..3e49cf79 100644
--- a/lib/websocket/opcode.go
+++ b/lib/websocket/opcode.go
@@ -10,10 +10,20 @@ type opcode byte
// List of valid operation code in frame.
//
const (
- opcodeCont opcode = 0x0
- opcodeText opcode = 0x1
- opcodeBin opcode = 0x2
- opcodeClose opcode = 0x8
- opcodePing opcode = 0x9
- opcodePong opcode = 0xA
+ opcodeCont opcode = 0x0
+ opcodeText opcode = 0x1
+ opcodeBin opcode = 0x2
+ opcodeDataRsv3 opcode = 0x3 // %x3-7 are reserved for further non-control frames
+ opcodeDataRsv4 opcode = 0x4
+ opcodeDataRsv5 opcode = 0x5
+ opcodeDataRsv6 opcode = 0x6
+ opcodeDataRsv7 opcode = 0x7
+ opcodeClose opcode = 0x8
+ opcodePing opcode = 0x9
+ opcodePong opcode = 0xA
+ opcodeControlRsvB opcode = 0xB // %xB-F are reserved for further control frames
+ opcodeControlRsvC opcode = 0xC
+ opcodeControlRsvD opcode = 0xD
+ opcodeControlRsvE opcode = 0xE
+ opcodeControlRsvF opcode = 0xF
)