private void AddNewClient(AionConnection client) { client.OnDisconnected += OnDisconnected; clients.Add(client.ClientID, client); client.StartReceivePacket(); log.InfoFormat("收到来自 {0} 的客户端连接!", (object)client.IP); }
private void OnDisconnected(object sender, EventArgs e) { AionConnection aionConnection = (AionConnection)sender; clients.Remove(aionConnection.ClientID); log.InfoFormat("来自 {0} 的客户端连接中断!", (object)aionConnection.IP); }
protected override void writeImpl(AionConnection con) { if (Operators.CompareString(ChatConfig.CLIENT_VERSION, "5.x", TextCompare: false) == 0) { writeC(0); writeD(_reader); writeD(0); writeD(_channel); writeD(_sender); writeD(0); writeC(0); } else { writeC(0); writeD(_channel); writeD(_sender); writeD(0); } checked { writeH((int)Math.Round((double)_identifier.Count() / 2.0)); writeB(_identifier); writeH((int)Math.Round((double)_message.Count() / 2.0)); writeB(_message); } }
protected override void writeImpl(AionConnection con) { writeC(64); writeH(_index); if (Operators.CompareString(ChatConfig.CLIENT_VERSION, "5.x", TextCompare: false) == 0) { writeH(0); } writeH(0); writeD(_channelId); }
public void AddPlayer(int playerId, AionConnection con) { lock (_connects) { if (_connects.ContainsKey(playerId)) { _connects[playerId].Disconnect(); _connects.Remove(playerId); } _connects.Add(playerId, con); } }
public void write(AionConnection con) { checked { using MemoryStream memoryStream = new MemoryStream(); base.Wbuf = new BinaryWriter(memoryStream); base.Wbuf.Write((short)0); base.Wbuf.Write((byte)base.OpCode); writeImpl(con); memoryStream.Position = 0L; base.Wbuf.Write((short)memoryStream.Length); base.PacketData = memoryStream.ToArray(); } }
protected override void writeImpl(AionConnection con) { writeC(64); writeH(1); if (Operators.CompareString(ChatConfig.CLIENT_VERSION, "5.x", TextCompare: false) == 0) { writeD(0); writeH(7442); } else { writeD(199032832); } }
internal void RegisterPlayerChannel(AionConnection con, short channelIndex, byte[] channelIdentifier) { int hashCode = Encoding.Unicode.GetString(channelIdentifier).GetHashCode(); if (!con.IsInChannel(hashCode)) { con.AddChannel(hashCode); } if (!_connects.ContainsKey(con.PlayerId)) { log.Warn((object)("进入频道异常 ID:" + Conversions.ToString(con.PlayerId))); _connects.Add(con.PlayerId, con); } con.SendPacket(new SM_CHANNEL_RESPONSE(channelIndex, hashCode)); }
internal void RegissterPlayerConnection(int serverId, int playerId, byte[] toKen, byte[] identifier, AionConnection client, string playerName, string accountName) { ChatClient value = null; if (!_players.TryGetValue(playerId, out value)) { return; } _players.Remove(playerId); byte[] toKen2 = value.ToKen; if (!value.SamePlayer(playerName)) { return; } bool flag = true; Array.ForEach(toKen, delegate(byte reg) { if (!toKen2.Contains(reg)) { flag = false; } }); if (flag) { byte[] bytes = Encoding.Unicode.GetBytes(value.PlayerName + "@"); value.Identifier = bytes.Concat(identifier).ToArray(); client.PlayerId = playerId; client.ServerId = serverId; client.ChatClient = value; AddPlayer(playerId, client); client.SendPacket(new SM_PLAYER_AUTH_RESPONSE()); log.InfoFormat("#{0} 玩家[{1}]进入聊天频道!", (object)serverId, (object)playerName); } }
internal static void RegisterPlayerChannel(AionConnection con, short channelIndex, byte[] channelIdentifier) { gameservers[con.ServerId].GameConnection.Chat.RegisterPlayerChannel(con, channelIndex, channelIdentifier); }
internal static void RegissterPlayerToServer(int serverId, int playerId, byte[] toKen, byte[] identifier, AionConnection client, string playerName, string accountName) { if (!gameservers.ContainsKey(serverId)) { log.WarnFormat("来自 {0} 的客户端尝试连接未注册的游戏服务器 ID:{1}", (object)client.IP, (object)serverId); client.Disconnect(); return; } GameInfo gameInfo = gameservers[serverId]; if (Information.IsNothing(gameInfo.GameConnection)) { log.WarnFormat("#{0}号游戏服务器尚未连接,来自{0}的客户端频道连接请求被拒绝!", (object)serverId, (object)client.IP); client.Disconnect(); } else { gameInfo.GameConnection.Chat.RegissterPlayerConnection(serverId, playerId, toKen, identifier, client, playerName, accountName); } }
protected abstract void writeImpl(AionConnection con);