示例#1
0
func (r *FightRoom) Enter(uid string, u FightUser) bool {
	if r.AddPeer(uid, u) {
		u.Send([]byte(proto.Encode(&proto.HCEnter{r.Name})))
		return true
	}
	return false
}
示例#2
0
文件: user.go 项目: princehuang/card
func (u *User) handle(msgType string, msgData interface{}) {
	switch msgType {
	case "chat":
		chatMsg := &proto.HCChat{u.Name, msgData.(string)}
		hall.Broadcast(proto.Encode(chatMsg))
	case "enterRoom":
		switch msgData.(string) {
		case "pvp":
			u.curRoom = room.EnterFightRoom(u.Name, u)
		case "pve":
		}
	}
}
示例#3
0
文件: hall.go 项目: princehuang/card
func Enter(uid string, u net.Peer) bool {
	ret := group.AddPeer(uid, u)
	if ret {
		msg := &proto.HCRoomList{}
		for k, _ := range configs {
			protoRoom := proto.Room{k, 0, fmt.Sprintf("#")}
			msg.Rooms = append(msg.Rooms, protoRoom)
		}

		fmt.Println(msg)
		u.Send([]byte(proto.Encode(msg)))
	}
	return ret
}