private void HandleJoinTunnelRequest(TcpSession session, Packet p) { var tunnelID = p.ReadUInt32(); var slotID = p.ReadByte(); //_logger.Debug("-C_JOIN_TUNNEL_REQ- Slot: {0} Tunnel: {1}", slotID, tunnelID); Player plr; if (!_players.TryGetValue(session.Guid, out plr)) { session.StopListening(); return; } Room room; if (!_rooms.TryGetValue(tunnelID, out room)) { room = new Room(_rooms, EServerType.Relay) { TunnelID = tunnelID }; _rooms.TryAdd(tunnelID, room); } room.Join(plr); plr.SlotID = slotID; var ack = new Packet(ERelayPacket.SResultAck); ack.Write((uint)3); // error code session.Send(ack); }
/// <summary> /// !!!!!!!!! /// id is team's id /// name is team's. if not null, creat, else get a specified team /// MarsPeer is one peer; /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="peer"></param> /// <returns></returns> public virtual Team GetTeamById(string id, string name, MarsPeer peer) //creat new...... { Team team = null; // lock (this.SyncRoot) { if (id == null || Rooms.TryGetValue(id, out team) == false) { if (name != null) { team = new Team(); team.teamId = (MinTeamID++).ToString();//Guid.NewGuid().ToString(); team.teamName = name; team.peers = new List <MarsPeer>(); Rooms.Add(team.teamId, team); } } if (team.peers.Contains(peer) == false) { team.peers.Add(peer); } } return(team); }