Documentation ¶
Index ¶
- Constants
- type ConnCallback
- type Connection
- func (c *Connection) Close()
- func (c *Connection) InitCloseHandler()
- func (c *Connection) ReadMessage() (messageType int, p []byte, err error)
- func (c *Connection) RegisterCloseFunctor(name string, function *Functor)
- func (c *Connection) RegisterConnectFunctor(name string, function *Functor)
- func (c *Connection) RemoteAddr() net.Addr
- func (c *Connection) WriteMessage(messageType int, data []byte) error
- type Functor
- type Message
- type WrapConnection
- func (wc *WrapConnection) AddOnCloseHandler(name string, function *Functor)
- func (wc *WrapConnection) AddOnConnectHandler(name string, function *Functor)
- func (wc *WrapConnection) Close()
- func (wc *WrapConnection) OnConnect()
- func (wc *WrapConnection) Read() (messageType int, p []byte, err error)
- func (wc *WrapConnection) Run()
- func (wc *WrapConnection) UpdateLastActiveTime(timestamp int64)
- func (wc *WrapConnection) Write(messageType int, data []byte) (err error)
Constants ¶
View Source
const DefaultReadTimeout = 2 * time.Second
View Source
const DefaultWriteBuff = 1024
View Source
const DefaultWriteTimeout = 2 * time.Second
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnCallback ¶
type ConnCallback interface { OnConnect(*WrapConnection) bool OnMessage(*WrapConnection, *Message) bool OnClose(*WrapConnection) }
type Connection ¶
type Connection struct { Mu sync.Mutex WebsocketConn *websocket.Conn // contains filtered or unexported fields }
func (*Connection) Close ¶
func (c *Connection) Close()
func (*Connection) InitCloseHandler ¶
func (c *Connection) InitCloseHandler()
func (*Connection) ReadMessage ¶
func (c *Connection) ReadMessage() (messageType int, p []byte, err error)
func (*Connection) RegisterCloseFunctor ¶
func (c *Connection) RegisterCloseFunctor(name string, function *Functor)
func (*Connection) RegisterConnectFunctor ¶
func (c *Connection) RegisterConnectFunctor(name string, function *Functor)
func (*Connection) RemoteAddr ¶
func (c *Connection) RemoteAddr() net.Addr
func (*Connection) WriteMessage ¶
func (c *Connection) WriteMessage(messageType int, data []byte) error
type WrapConnection ¶
type WrapConnection struct { Connection *Connection PlayerId string IsClosed atomic.Bool ReadTimeout time.Duration WriteTimeout time.Duration LastActiveTime *atomic.Int64 // contains filtered or unexported fields }
func NewWrapConn ¶
func NewWrapConn(conn *websocket.Conn, playerId string, server ConnCallback) *WrapConnection
func (*WrapConnection) AddOnCloseHandler ¶
func (wc *WrapConnection) AddOnCloseHandler(name string, function *Functor)
func (*WrapConnection) AddOnConnectHandler ¶
func (wc *WrapConnection) AddOnConnectHandler(name string, function *Functor)
func (*WrapConnection) Close ¶
func (wc *WrapConnection) Close()
func (*WrapConnection) OnConnect ¶
func (wc *WrapConnection) OnConnect()
func (*WrapConnection) Read ¶
func (wc *WrapConnection) Read() (messageType int, p []byte, err error)
func (*WrapConnection) Run ¶
func (wc *WrapConnection) Run()
func (*WrapConnection) UpdateLastActiveTime ¶
func (wc *WrapConnection) UpdateLastActiveTime(timestamp int64)
Click to show internal directories.
Click to hide internal directories.