-
Notifications
You must be signed in to change notification settings - Fork 41
/
hubprotocol.go
72 lines (62 loc) · 1.97 KB
/
hubprotocol.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package signalr
import (
"bytes"
"io"
)
// hubProtocol interface
// ParseMessages() parses messages from an io.Reader and stores unparsed bytes in remainBuf.
// If buf does not contain the whole message, it returns a nil message and complete false
// WriteMessage writes a message to the specified writer
// UnmarshalArgument() unmarshals a raw message depending of the specified value type into a destination value
type hubProtocol interface {
ParseMessages(reader io.Reader, remainBuf *bytes.Buffer) ([]interface{}, error)
WriteMessage(message interface{}, writer io.Writer) error
UnmarshalArgument(src interface{}, dst interface{}) error
setDebugLogger(dbg StructuredLogger)
transferMode() TransferMode
}
//easyjson:json
type hubMessage struct {
Type int `json:"type"`
}
// easyjson:json
type invocationMessage struct {
Type int `json:"type"`
Target string `json:"target"`
InvocationID string `json:"invocationId,omitempty"`
Arguments []interface{} `json:"arguments"`
StreamIds []string `json:"streamIds,omitempty"`
}
//easyjson:json
type completionMessage struct {
Type int `json:"type"`
InvocationID string `json:"invocationId"`
Result interface{} `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
//easyjson:json
type streamItemMessage struct {
Type int `json:"type"`
InvocationID string `json:"invocationId"`
Item interface{} `json:"item"`
}
//easyjson:json
type cancelInvocationMessage struct {
Type int `json:"type"`
InvocationID string `json:"invocationId"`
}
//easyjson:json
type closeMessage struct {
Type int `json:"type"`
Error string `json:"error"`
AllowReconnect bool `json:"allowReconnect"`
}
//easyjson:json
type handshakeRequest struct {
Protocol string `json:"protocol"`
Version int `json:"version"`
}
//easyjson:json
type handshakeResponse struct {
Error string `json:"error,omitempty"`
}