-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.go
52 lines (44 loc) · 1.39 KB
/
type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package go_engine_io_parser
//go:generate stringer -type=Type
// Type is the type of packet.
type Type byte
const (
// Open is sent from the server when new transport is Opened (recheck).
Open Type = iota
// Close is request the Close of this transport but does not shutdown the
// connection itself.
Close
// Ping is sent by the client. Server should answer with a Pong packet
// containing the same data.
Ping
// Pong is sent by the server to respond to Ping packets.
Pong
// Message is actual Message, client and server should call their callbacks
// with the data.
Message
// Upgrade is sent before engine.io switches transport to test if server
// and client can communicate over this transport. If this test succeeds,
// the client sends an Upgrade packets which requests the server to flush
// its cache on the old transport and switch to the new transport.
Upgrade
// Noop is a Noop packet. Used primarily to force a poll cycle when an
// incoming websocket connection is received.
Noop
Error
)
// StringByte converts a PacketType to byte in string.
func (i Type) StringByte() byte {
return byte(i) + TerminateSymbol
}
// Byte converts a PacketType to byte in binary.
func (i Type) Byte() byte {
return byte(i)
}
type Options struct {
Compress bool
}
type Packet struct {
Type Type
Options *Options
Data interface{} // string | Buffer | ArrayBuffer | ArrayBufferView | Blob
}