Documentation
¶
Index ¶
- Variables
- type BaseChannel
- type Channel
- type Listener
- type Listeners
- func (listeners Listeners) OnClose(channel Channel, closeInfo string)
- func (listeners Listeners) OnFailure(w http.ResponseWriter, r *http.Request, failureInfo string)
- func (listeners Listeners) OnHandshake(w http.ResponseWriter, r *http.Request, channel Channel)
- func (listeners Listeners) OnMessage(channel Channel, messageType int, data []byte)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ChannelClosedError = errorKit.New("Channel is already closed")
)
Functions ¶
This section is empty.
Types ¶
type BaseChannel ¶
type BaseChannel struct { Id string Bsid string User string Group string RWMutex mutexKit.RWMutex Data interface{} Closed bool Listeners Listeners }
func (*BaseChannel) IsClosed ¶
func (channel *BaseChannel) IsClosed() (rst bool)
func (*BaseChannel) SetClosed ¶
func (channel *BaseChannel) SetClosed() (flag bool)
SetClosed
PS: 如果返回值为true,应当触发 listener.onClose().
@return true: 设置成功
false: 设置失败(因为已经被设置关闭)
type Listener ¶
type Listener interface { OnFailure(w http.ResponseWriter, r *http.Request, failureInfo string) OnHandshake(w http.ResponseWriter, r *http.Request, channel Channel) // OnMessage 收到 客户端 发来的消息. /* PS: 仅适用于WebSocket连接,因为SSE连接是单工的. */ OnMessage(channel Channel, messageType int, data []byte) OnClose(channel Channel, closeInfo string) }
Click to show internal directories.
Click to hide internal directories.