ww

package
v0.0.0-...-61829c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// for business message
	WSMessageTypeBusiness = WSMessageType(1)
	// for control message (close connection)
	WSMessageTypeClose = WSMessageType(2)
)

Variables

This section is empty.

Functions

func Debug

func Debug(format string, v ...interface{})

func Error

func Error(format string, v ...interface{})

func Info

func Info(format string, v ...interface{})

func Notice

func Notice(format string, v ...interface{})

func SetLogger

func SetLogger(l logger)

func Warning

func Warning(format string, v ...interface{})

Types

type WSClient

type WSClient struct {
	// contains filtered or unexported fields
}

func (*WSClient) RefreshReconnectMsg

func (ws *WSClient) RefreshReconnectMsg(reconnectMsg *WSMessage)

RefreshReconnectMsg can refresh the client's reconnect message

func (*WSClient) SendMessge

func (ws *WSClient) SendMessge(msg *WSMessage) (err error)

func (*WSClient) Shutdown

func (ws *WSClient) Shutdown() error

func (*WSClient) Startup

func (ws *WSClient) Startup(remoteAddr, remotePath string, reconnectTime time.Duration,
	onMessage func([]byte, error), onClose func(), reconnectMsg *WSMessage) error

type WSHandle

type WSHandle uint64

WSHandle means a websocket connection

func (WSHandle) SendMessage

func (h WSHandle) SendMessage(msg *WSMessage) (err error)

SendMessge ,send a message to chan

type WSMessage

type WSMessage struct {
	// Type determine the message is business message or not
	Type WSMessageType
	// Data save the concrete datas for translation
	Data []byte
}

type WSMessageType

type WSMessageType int64

type WSServerHandler

type WSServerHandler struct {
	On WSServerInterface
}

func (*WSServerHandler) OnHandler

func (ws *WSServerHandler) OnHandler(w http.ResponseWriter, r *http.Request)

OnHandler contains a connection and open a routine for recv

type WSServerInterface

type WSServerInterface interface {
	OnMessage(WSHandle, []byte, error)
	OnClose(WSHandle)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL