-
Notifications
You must be signed in to change notification settings - Fork 76
/
response.go
29 lines (23 loc) · 702 Bytes
/
response.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
package gotalk
import "time"
type Response struct {
MsgType
Data []byte
Wait time.Duration // only valid when IsRetry()==true
}
// Returns a string describing the error, when IsError()==true
func (r *Response) Error() string {
return string(r.Data)
}
// True if this response is a requestor error (ErrorResult)
func (r *Response) IsError() bool {
return r.MsgType == MsgTypeErrorRes
}
// True if response is a "server can't handle it right now, please retry" (RetryResult)
func (r *Response) IsRetry() bool {
return r.MsgType == MsgTypeRetryRes
}
// True if this is part of a streaming response (StreamResult)
func (r *Response) IsStreaming() bool {
return r.MsgType == MsgTypeStreamRes
}