Example #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
}
Example #2
0
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":
		}
	}
}
Example #3
0
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
}