-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtypes.go
45 lines (36 loc) · 971 Bytes
/
types.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
package stubborn
import (
"context"
"time"
)
const (
TextMessage = 1
BinaryMessage = 2
PingMessage = 9
PongMessage = 10
)
type (
DuplexConnector interface {
Close() error
ReadMessage() (messageType int, p []byte, err error)
WriteMessage(messageType int, data []byte) error
}
KeepAlive struct {
Tick time.Duration
CustomPing func() (msgType int, payload []byte)
CustomPong func(msgTp int, data []byte) (msgType int, payload []byte)
}
DialerFunc func(ctx context.Context) (DuplexConnector, error)
AuthHandler func() (req []byte, resp []byte, err error)
MessageHandler func(resp []byte)
ErrorHandler func(err error)
CustomLogger interface {
Infoln(args ...interface{})
Debugln(args ...interface{})
Errorln(args ...interface{})
}
defaultLogger struct{}
)
func (defaultLogger) Infoln(args ...interface{}) {}
func (defaultLogger) Debugln(args ...interface{}) {}
func (defaultLogger) Errorln(args ...interface{}) {}