Versions in this module Expand all Collapse all v1 v1.1.5 Oct 13, 2019 v1.1.2 Aug 15, 2019 v1.1.0 Aug 15, 2019 v1.0.0 Aug 15, 2019 Changes in this version + const GB + const KB + const MB + const TB + var ErrUnauthorized = errors.New(http.StatusText(http.StatusUnauthorized)) + var Return = new(ReturnJSON) + var StdLogger = log.New(os.Stdout, "[WSlt] ", log.LstdFlags) + type BusinessHandler func(*Context) + type BusinessMessage struct + Data jsoniter.RawMessage + StringType string + func DecodeBiMessage(data []byte) (msg *BusinessMessage, err error) + func NewBusinessMessage(stringType string, data interface{}) (msg *BusinessMessage, err error) + func (b *BusinessMessage) UnmarshalData(v interface{}) error + type Client struct + func NewClient(urlStr string) (ws *Client, err error) + func (c *Client) AddCallHandler(rid string, handler ws_rpc.CallHandler) + func (c *Client) Close() + func (c *Client) CloseChan() <-chan byte + func (c *Client) Dial(urlStr string) (err error) + func (c *Client) GetHandler(rid string) (handler ws_rpc.CallHandler, ok bool) + func (c *Client) IsClosed() (closed bool) + func (c *Client) ReadHandle(typeStr string, handler ClientBusinessHandler) + func (c *Client) RemoveHandler(rid string) + func (c *Client) SendMessage(typeString string, msgData interface{}) (err error) + type ClientBusinessHandler func(*ClientContext) + type ClientContext struct + Message *BusinessMessage + type Connection struct + func (c *Connection) Close() + func (c *Connection) Connector() Connector + func (c *Connection) GetConn() (conn *websocket.Conn) + func (c *Connection) IsClosed() (closed bool) + func (c *Connection) SendMessage(businessType string, businessMessage interface{}) (err error) + func (c *Connection) SessionID() int64 + func (c *Connection) Ws() *WSocket + type Connector interface + CheckAuth func(token string, wConn *websocket.Conn) error + Connection func() *Connection + GetID func() int64 + NewInstance func() Connector + SetConnection func(conn *Connection) + type ConnectorHandler func() Connector + type Context struct + Message *BusinessMessage + func (ctx *Context) BindCallRequest() (msg *ws_rpc.CallMsg, err error) + func (ctx *Context) SendCallBackMsg(callMsg *ws_rpc.CallMsg, data interface{}) + type IterationConnectionsFunc func(id int64, connection *Connection) bool + type RawClient struct + func NewRawClient(urlStr string) (ws *RawClient, err error) + func (c *RawClient) Close() + func (c *RawClient) CloseChan() <-chan byte + func (c *RawClient) Dial(urlStr string) (err error) + func (c *RawClient) IsClosed() (closed bool) + func (c *RawClient) ReadMessage() (raw []byte, err error) + func (c *RawClient) SendMessage(typeString string, msgData interface{}) (err error) + type ReturnJSON struct + Code int + Message interface{} + StatusText string + func (r *ReturnJSON) Ok(i interface{}) *ReturnJSON + func (r *ReturnJSON) Set(code int, msg interface{}) *ReturnJSON + type Session struct + SID int64 + func GlobalSession() *Session + func (s *Session) GetSidsByConnectorID(ctID int64) (sids []int64) + func (s *Session) UnUsedSids() []int64 + type SessionRelationShip struct + type WSocket struct + func New() *WSocket + func (w *WSocket) Handler(connector Connector) http.HandlerFunc + func (w *WSocket) IterationConnections(fn IterationConnectionsFunc) + func (w *WSocket) ReadHandle(msgType string, handler BusinessHandler) + func (w *WSocket) SendToAll(msgType string, data interface{}) (err error) + type WebContext struct + func (c *WebContext) IsWebSocket() bool + func (c *WebContext) JSON(code int, data interface{}) + type WsMessage struct + Data []byte + MessageType int + func CreateWsMessage(msgType string, data interface{}) (msg *WsMessage, err error) + func NewWsMessage(messageType int, date []byte) *WsMessage