Documentation ¶
Index ¶
- Variables
- func Response(res http.ResponseWriter, response IResponse)
- type Connection
- func (wsc *Connection) Close()
- func (wsc *Connection) GetRoom() string
- func (wsc *Connection) GetUniqueKey() string
- func (wsc *Connection) Send(b []byte)
- func (wsc *Connection) SetRoom(room string)
- func (wsc *Connection) WriteBytes(message []byte) error
- func (wsc *Connection) WriteString(message string) error
- type DefaultResponse
- type IConfig
- type IError
- type ILog
- type IMessage
- type IResponse
- type Protocol
- func (w *Protocol) All(room string) []*Connection
- func (w *Protocol) GetNumber() uint64
- func (w *Protocol) OffLine(conn *Connection)
- func (w *Protocol) Online(conn *Connection)
- func (w *Protocol) Run()
- func (w *Protocol) Send(msg IMessage)
- func (w *Protocol) ServeHTTP(rw http.ResponseWriter, r *http.Request)
- type RoomMsg
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorResponse = DefaultResponse{
Code: "200",
Msg: "操作失败",
}
View Source
var SuccessResponse = DefaultResponse{
Code: "200",
Msg: "操作成功",
}
Functions ¶
func Response ¶
func Response(res http.ResponseWriter, response IResponse)
Types ¶
type Connection ¶
type Connection struct { *websocket.Conn UniqueKey string CLog ILog Config IConfig // contains filtered or unexported fields }
func (*Connection) GetRoom ¶
func (wsc *Connection) GetRoom() string
func (*Connection) GetUniqueKey ¶
func (wsc *Connection) GetUniqueKey() string
func (*Connection) Send ¶
func (wsc *Connection) Send(b []byte)
func (*Connection) SetRoom ¶
func (wsc *Connection) SetRoom(room string)
func (*Connection) WriteBytes ¶
func (wsc *Connection) WriteBytes(message []byte) error
func (*Connection) WriteString ¶
func (wsc *Connection) WriteString(message string) error
type DefaultResponse ¶
type DefaultResponse struct { Code string `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` }
func (DefaultResponse) Error ¶
func (res DefaultResponse) Error() string
func (DefaultResponse) GetCode ¶
func (res DefaultResponse) GetCode() int
func (DefaultResponse) GetData ¶
func (res DefaultResponse) GetData() interface{}
func (DefaultResponse) ToJsonBytes ¶
func (res DefaultResponse) ToJsonBytes() []byte
func (DefaultResponse) ToJsonString ¶
func (res DefaultResponse) ToJsonString() string
type Protocol ¶
type Protocol struct { //all connections, It's mapping O(1) ConnectionsMap map[string]*sync.Map //send and received message Msg chan IMessage //log PLog ILog //upgrade check logic CheckOrigin func(r *http.Request) bool //upgrade error handler UpErrorHandler func(res http.ResponseWriter, r *http.Request, status int, reason error) //config Config IConfig // contains filtered or unexported fields }
var Wsp *Protocol
Source Files ¶
Click to show internal directories.
Click to hide internal directories.