示例#1
0
        /// <summary>
        /// Read and process Tell message
        /// </summary>
        /// <param name="client">
        /// Client sending
        /// </param>
        /// <param name="packet">
        /// Packet data
        /// </param>
        public static void Read(Client client, byte[] packet)
        {
            PacketReader reader = new PacketReader(ref packet);

            reader.ReadUInt16();
            reader.ReadUInt16();
            uint   playerId = reader.ReadUInt32();
            string message  = reader.ReadString();

            client.Server.Debug(client, "{0} >> Tell: PlayerId: {1}", client.Character.characterName, playerId);
            reader.Finish();
            if (client.Server.ConnectedClients.ContainsKey(playerId))
            {
                Client tellClient = (Client)client.Server.ConnectedClients[playerId];
                if (!tellClient.KnownClients.Contains(client.Character.characterId))
                {
                    byte[] pname = PlayerName.New(client, client.Character.characterId);
                    tellClient.Send(pname);
                    tellClient.KnownClients.Add(client.Character.characterId);
                }

                byte[] pgroup = MsgPrivateGroup.Create(client.Character.characterId, message, string.Empty);
                tellClient.Send(pgroup);
            }
            else
            {
                byte[] sysmsg = MsgSystem.Create("Player not online.");
                client.Send(sysmsg);
            }
        }
示例#2
0
        /// <summary>
        /// Read and process Tell message
        /// </summary>
        /// <param name="client">
        /// Client sending
        /// </param>
        /// <param name="packet">
        /// Packet data
        /// </param>
        public static void Read(Client client, byte[] packet)
        {
            PacketReader reader = new PacketReader(ref packet);

            reader.ReadUInt16();
            reader.ReadUInt16();
            uint   playerId = reader.ReadUInt32();
            string message  = reader.ReadString();

            client.Server.Debug(client, "{0} >> Tell: PlayerId: {1}", client.Character.characterName, playerId);
            reader.Finish();
            if (client.ChatServer().ConnectedClients.ContainsKey(playerId))
            {
                Client tellClient = (Client)client.ChatServer().ConnectedClients[playerId];
                if (!tellClient.KnownClients.Contains(client.Character.CharacterId))
                {
                    byte[] pname = PlayerName.Create(client, client.Character.CharacterId);
                    tellClient.Send(pname);
                    tellClient.KnownClients.Add(client.Character.CharacterId);

                    // TODO: Check if status bytes are correct even for offline chars
                    client.Send(
                        BuddyOnlineStatus.Create(
                            (uint)tellClient.Character.CharacterId,
                            (uint)OnlineDao.IsOnline((int)tellClient.Character.CharacterId).Online,
                            new byte[] { 0x00, 0x01, 0x00 }));
                }

                byte[] pgroup = MsgPrivateGroup.Create(client.Character.CharacterId, message, string.Empty);
                tellClient.Send(pgroup);
            }
            else
            {
                byte[] sysmsg = MsgSystem.Create("Player not online.");
                client.Send(sysmsg);
            }
        }