Documentation ¶
Index ¶
- Constants
- Variables
- type BusinessHandler
- type BusinessMessage
- type Client
- 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
- type ClientContext
- type Connection
- 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
- type ConnectorHandler
- type Context
- type IterationConnectionsFunc
- type RawClient
- 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
- type Session
- type SessionRelationShip
- type WSocket
- type WebContext
- type WsMessage
Constants ¶
View Source
const ( KB int64 = 1 << (10 * iota) // 1 << (10*1) MB // 1 << (10*2) GB // 1 << (10*3) TB // 1 << (10*4) )
Variables ¶
View Source
var ( errors.New(http.StatusText(http.StatusUnauthorized)) )ErrUnauthorized =
View Source
var (
Return = new(ReturnJSON)
)
Functions ¶
This section is empty.
Types ¶
type BusinessHandler ¶
type BusinessHandler func(*Context)
type BusinessMessage ¶
type BusinessMessage struct { StringType string Data jsoniter.RawMessage }
func DecodeBiMessage ¶
func DecodeBiMessage(data []byte) (msg *BusinessMessage, err error)
func NewBusinessMessage ¶
func NewBusinessMessage(stringType string, data interface{}) (msg *BusinessMessage, err error)
func (*BusinessMessage) UnmarshalData ¶
func (b *BusinessMessage) UnmarshalData(v interface{}) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AddCallHandler ¶
func (c *Client) AddCallHandler(rid string, handler ws_rpc.CallHandler)
func (*Client) GetHandler ¶
func (c *Client) GetHandler(rid string) (handler ws_rpc.CallHandler, ok bool)
func (*Client) ReadHandle ¶
func (c *Client) ReadHandle(typeStr string, handler ClientBusinessHandler)
ReadHandle 设置客户端读取操作函数
func (*Client) RemoveHandler ¶
func (*Client) SendMessage ¶
SendMessage msgData is a BusinessMessage's RawData
type ClientBusinessHandler ¶
type ClientBusinessHandler func(*ClientContext)
type ClientContext ¶
type ClientContext struct { *Client Message *BusinessMessage }
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection a websocket connection
func (*Connection) Close ¶
func (c *Connection) Close()
func (*Connection) Connector ¶
func (c *Connection) Connector() Connector
func (*Connection) GetConn ¶
func (c *Connection) GetConn() (conn *websocket.Conn)
func (*Connection) IsClosed ¶
func (c *Connection) IsClosed() (closed bool)
func (*Connection) SendMessage ¶
func (c *Connection) SendMessage(businessType string, businessMessage interface{}) (err error)
func (*Connection) SessionID ¶
func (c *Connection) SessionID() int64
func (*Connection) Ws ¶
func (c *Connection) Ws() *WSocket
type Connector ¶
type Connector interface { //SetConnection ... SetConnection(conn *Connection) Connection() *Connection //CheckAuth check the connector's Auth NewInstance() Connector CheckAuth(token string, wConn *websocket.Conn) error GetID() int64 }
Connector example:a user
type ConnectorHandler ¶
type ConnectorHandler func() Connector
type Context ¶
type Context struct { *Connection Message *BusinessMessage }
func (*Context) BindCallRequest ¶
func (*Context) SendCallBackMsg ¶
SendCallBackMsg Sending synchronous messages
type IterationConnectionsFunc ¶
type IterationConnectionsFunc func(id int64, connection *Connection) bool
WSocket ...
type RawClient ¶
type RawClient struct {
// contains filtered or unexported fields
}
func NewRawClient ¶
func (*RawClient) ReadMessage ¶
func (*RawClient) SendMessage ¶
msgData is a BusinessMessage's RawData
type ReturnJSON ¶
type ReturnJSON struct { Code int `json:"code"` StatusText string `json:"status_text"` Message interface{} `json:"message,omitempty"` }
func (*ReturnJSON) Ok ¶
func (r *ReturnJSON) Ok(i interface{}) *ReturnJSON
func (*ReturnJSON) Set ¶
func (r *ReturnJSON) Set(code int, msg interface{}) *ReturnJSON
type Session ¶
type Session struct { SID int64 `json:"sid"` // contains filtered or unexported fields }
func (*Session) GetSidsByConnectorID ¶
func (*Session) UnUsedSids ¶
type SessionRelationShip ¶
type SessionRelationShip struct {
// contains filtered or unexported fields
}
type WSocket ¶
type WSocket struct {
// contains filtered or unexported fields
}
WSocket ...
func (*WSocket) IterationConnections ¶
func (w *WSocket) IterationConnections(fn IterationConnectionsFunc)
func (*WSocket) ReadHandle ¶
func (w *WSocket) ReadHandle(msgType string, handler BusinessHandler)
type WebContext ¶
type WebContext struct {
// contains filtered or unexported fields
}
func (*WebContext) IsWebSocket ¶
func (c *WebContext) IsWebSocket() bool
func (*WebContext) JSON ¶
func (c *WebContext) JSON(code int, data interface{})
Source Files ¶
Click to show internal directories.
Click to hide internal directories.