Documentation ¶
Index ¶
- Variables
- func Response(rsp []MessageRsp)
- type Hall
- type MessageRsp
- type Room
- func (r *Room) GetPlayerIds() (ids []int64)
- func (r *Room) Join(playerId int64) (err error)
- func (r *Room) Notify(playerId int64) (err error)
- func (r *Room) Receive(ctx context.Context, pid int64, validator func(msg *model.Message) bool) (msg model.Message, err error)
- func (r *Room) ReceiveAll(validator func(msg *model.Message) bool) (msgs []model.Message, err error)
- func (r *Room) Send(pid int64, messageType model.MessageType, raw interface{}) (err error)
- func (r *Room) Service()
- func (r *Room) Start()
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrTimeOut = errors.New("timeout")
)
View Source
var Rooms map[int64]*Room
Functions ¶
func Response ¶
func Response(rsp []MessageRsp)
Types ¶
type MessageRsp ¶
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
处理在房间内的所有用户消息
func CreateRoom ¶
func (*Room) GetPlayerIds ¶
func (*Room) Receive ¶
func (r *Room) Receive(ctx context.Context, pid int64, validator func(msg *model.Message) bool) (msg model.Message, err error)
接收一个消息, ctx超时控制
func (*Room) ReceiveAll ¶
func (r *Room) ReceiveAll(validator func(msg *model.Message) bool) (msgs []model.Message, err error)
接收任何一个消息
Click to show internal directories.
Click to hide internal directories.