github.com/philippseith/signalr@v0.6.3/hubprotocol.go (about) 1 package signalr 2 3 import ( 4 "bytes" 5 "io" 6 ) 7 8 // hubProtocol interface 9 // ParseMessages() parses messages from an io.Reader and stores unparsed bytes in remainBuf. 10 // If buf does not contain the whole message, it returns a nil message and complete false 11 // WriteMessage writes a message to the specified writer 12 // UnmarshalArgument() unmarshals a raw message depending of the specified value type into a destination value 13 type hubProtocol interface { 14 ParseMessages(reader io.Reader, remainBuf *bytes.Buffer) ([]interface{}, error) 15 WriteMessage(message interface{}, writer io.Writer) error 16 UnmarshalArgument(src interface{}, dst interface{}) error 17 setDebugLogger(dbg StructuredLogger) 18 transferMode() TransferMode 19 } 20 21 //easyjson:json 22 type hubMessage struct { 23 Type int `json:"type"` 24 } 25 26 // easyjson:json 27 type invocationMessage struct { 28 Type int `json:"type"` 29 Target string `json:"target"` 30 InvocationID string `json:"invocationId,omitempty"` 31 Arguments []interface{} `json:"arguments"` 32 StreamIds []string `json:"streamIds,omitempty"` 33 } 34 35 //easyjson:json 36 type completionMessage struct { 37 Type int `json:"type"` 38 InvocationID string `json:"invocationId"` 39 Result interface{} `json:"result,omitempty"` 40 Error string `json:"error,omitempty"` 41 } 42 43 //easyjson:json 44 type streamItemMessage struct { 45 Type int `json:"type"` 46 InvocationID string `json:"invocationId"` 47 Item interface{} `json:"item"` 48 } 49 50 //easyjson:json 51 type cancelInvocationMessage struct { 52 Type int `json:"type"` 53 InvocationID string `json:"invocationId"` 54 } 55 56 //easyjson:json 57 type closeMessage struct { 58 Type int `json:"type"` 59 Error string `json:"error"` 60 AllowReconnect bool `json:"allowReconnect"` 61 } 62 63 //easyjson:json 64 type handshakeRequest struct { 65 Protocol string `json:"protocol"` 66 Version int `json:"version"` 67 } 68 69 //easyjson:json 70 type handshakeResponse struct { 71 Error string `json:"error,omitempty"` 72 }