Documentation ¶
Index ¶
- Variables
- func ClientIP(c *http.Request) string
- func InitWsServer()
- func NewPushTask(roomLen, workNum, taskNum int)
- func NewRoomManage()
- type PushJob
- type PushManage
- type PushTask
- type Room
- type RoomManage
- func (r *RoomManage) AddConn(ws *WsConnection)
- func (r *RoomManage) AddRoom(id int, wsId string) error
- func (r *RoomManage) DelConn(ws *WsConnection)
- func (r *RoomManage) LeaveRoom(id int, wsId string) error
- func (r *RoomManage) NewRoom(id int, title string) error
- func (r *RoomManage) PushAll(msg *WSMessage)
- func (r *RoomManage) PushRoom(id int, msg *WSMessage) error
- type WSMessage
- type WsConnection
- func (w *WsConnection) CloseConn()
- func (w *WsConnection) GetIp() string
- func (w *WsConnection) GetWsId() string
- func (w *WsConnection) ReadMsg() (message *WSMessage, err error)
- func (w *WsConnection) SendMsg(msg *WSMessage) (err error)
- func (w *WsConnection) SetIp(ip string)
- func (w *WsConnection) WsHandle()
Constants ¶
This section is empty.
Variables ¶
View Source
var (
RoomTitle = []string{"健身", "体育", "电影", "音乐"}
)
View Source
var (
WsErrConnLoss = errors.New("conn already close")
)
Functions ¶
func InitWsServer ¶
func InitWsServer()
func NewPushTask ¶
func NewPushTask(roomLen, workNum, taskNum int)
func NewRoomManage ¶
func NewRoomManage()
Types ¶
type PushManage ¶
type PushManage interface {
Push(job *PushJob)
}
func GetPushManage ¶
func GetPushManage() PushManage
type RoomManage ¶
func GetRoomManage ¶
func GetRoomManage() *RoomManage
func (*RoomManage) AddConn ¶
func (r *RoomManage) AddConn(ws *WsConnection)
func (*RoomManage) DelConn ¶
func (r *RoomManage) DelConn(ws *WsConnection)
func (*RoomManage) PushAll ¶
func (r *RoomManage) PushAll(msg *WSMessage)
type WsConnection ¶
type WsConnection struct {
// contains filtered or unexported fields
}
func NewWsConnection ¶
func NewWsConnection(conn *websocket.Conn) *WsConnection
func (*WsConnection) CloseConn ¶
func (w *WsConnection) CloseConn()
func (*WsConnection) GetIp ¶
func (w *WsConnection) GetIp() string
func (*WsConnection) GetWsId ¶
func (w *WsConnection) GetWsId() string
func (*WsConnection) ReadMsg ¶
func (w *WsConnection) ReadMsg() (message *WSMessage, err error)
func (*WsConnection) SendMsg ¶
func (w *WsConnection) SendMsg(msg *WSMessage) (err error)
func (*WsConnection) SetIp ¶
func (w *WsConnection) SetIp(ip string)
func (*WsConnection) WsHandle ¶
func (w *WsConnection) WsHandle()
Click to show internal directories.
Click to hide internal directories.