Documentation
¶
Index ¶
- Constants
- Variables
- func DumpResponse(resp *http.Response, body bool)
- func Run(wssUrl string, header http.Header) (msgChan chan []byte, err error)
- func Stop()
- type WssClient
- func (w *WssClient) Channel() (chan []byte, error)
- func (w *WssClient) Close()
- func (w *WssClient) Config(opts ...WssClientOpt) *WssClient
- func (w *WssClient) Conn() *websocket.Conn
- func (w *WssClient) Connect() error
- func (w *WssClient) ReceiveMsg()
- func (w *WssClient) Sub(ch string) error
- func (w *WssClient) SubAll() error
- func (w *WssClient) Subs(chs []string)
- func (w *WssClient) UnSubAll() error
- func (w *WssClient) UnSubs()
- func (w *WssClient) Unsub(ch string) error
- func (w *WssClient) WriteControl(messageType int, msg []byte, deadline time.Time) error
- func (w *WssClient) WriteMessage(messageType int, msg []byte) error
- type WssClientOpt
- func WithAfterConnectedFunc(fn func() error) WssClientOpt
- func WithChannel(channel chan []byte) WssClientOpt
- func WithHeader(header http.Header) WssClientOpt
- func WithIsAutoReconnect(is bool) WssClientOpt
- func WithIsDump(is bool) WssClientOpt
- func WithMessageFunc(fn func(msg []byte) error) WssClientOpt
- func WithReconnectCount(c int) WssClientOpt
- func WithReconnectInterval(i time.Duration) WssClientOpt
- func WithSubFnc(fn func(string) string) WssClientOpt
- func WithSubs(fn func() []string) WssClientOpt
- func WithSystemErrorFunc(fn func(error)) WssClientOpt
- func WithUncompressFunc(fn func([]byte) ([]byte, error)) WssClientOpt
- func WithUnsubFnc(fn func(string) string) WssClientOpt
- func WithWsUrl(url string) WssClientOpt
Constants ¶
View Source
const ( NotConnected = iota Connected )
View Source
const ( EventCallback = iota EventChannel )
Variables ¶
Functions ¶
func DumpResponse ¶
Types ¶
type WssClient ¶
type WssClient struct {
sync.Mutex
SubFunc func(ch string) string
UnsubFunc func(ch string) string
MsgFunc func(msg []byte) error
UncompressedFunc func(msg []byte) ([]byte, error)
SystemErrFunc func(err error)
AfterConnectedFunc func() error
// contains filtered or unexported fields
}
func New ¶
func New(opts ...WssClientOpt) *WssClient
func (*WssClient) Config ¶
func (w *WssClient) Config(opts ...WssClientOpt) *WssClient
func (*WssClient) ReceiveMsg ¶
func (w *WssClient) ReceiveMsg()
func (*WssClient) WriteControl ¶
type WssClientOpt ¶
type WssClientOpt func(c *WssClient)
func WithAfterConnectedFunc ¶
func WithAfterConnectedFunc(fn func() error) WssClientOpt
func WithChannel ¶
func WithChannel(channel chan []byte) WssClientOpt
func WithHeader ¶
func WithHeader(header http.Header) WssClientOpt
func WithIsAutoReconnect ¶
func WithIsAutoReconnect(is bool) WssClientOpt
func WithIsDump ¶
func WithIsDump(is bool) WssClientOpt
func WithMessageFunc ¶
func WithMessageFunc(fn func(msg []byte) error) WssClientOpt
func WithReconnectCount ¶
func WithReconnectCount(c int) WssClientOpt
func WithReconnectInterval ¶
func WithReconnectInterval(i time.Duration) WssClientOpt
func WithSubFnc ¶
func WithSubFnc(fn func(string) string) WssClientOpt
func WithSubs ¶
func WithSubs(fn func() []string) WssClientOpt
func WithSystemErrorFunc ¶
func WithSystemErrorFunc(fn func(error)) WssClientOpt
func WithUncompressFunc ¶
func WithUncompressFunc(fn func([]byte) ([]byte, error)) WssClientOpt
func WithUnsubFnc ¶
func WithUnsubFnc(fn func(string) string) WssClientOpt
func WithWsUrl ¶
func WithWsUrl(url string) WssClientOpt
Click to show internal directories.
Click to hide internal directories.