当前位置: 首页>>代码示例>>C#>>正文


C# PacketWriter.ReadDataToSend方法代码示例

本文整理汇总了C#中Framework.Network.Packets.PacketWriter.ReadDataToSend方法的典型用法代码示例。如果您正苦于以下问题:C# PacketWriter.ReadDataToSend方法的具体用法?C# PacketWriter.ReadDataToSend怎么用?C# PacketWriter.ReadDataToSend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Framework.Network.Packets.PacketWriter的用法示例。


在下文中一共展示了PacketWriter.ReadDataToSend方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WritePacket

        public static void WritePacket(string clientInfo, PacketWriter serverPacket = null, PacketReader clientPacket = null)
        {
            lock (syncObj)
            {
                try
                {
                    StringBuilder sb = new StringBuilder();
                    TimeSpan       t = DateTime.UtcNow - new DateTime(1970, 1, 1);

                    uint secondsSinceEpoch = (uint)t.TotalSeconds;

                    if (serverPacket != null)
                    {
                        sb.Append(string.Format("Time: {0};OpcodeType: SMSG;OpcodeValue: {1};Packet: ", secondsSinceEpoch, (ushort)serverPacket.Opcode));

                        if (serverPacket.Size - 2 != 0)
                        {
                            var data = serverPacket.ReadDataToSend().ToList();
                            data.RemoveRange(0, 4);

                            data.ForEach(b =>
                            {
                                sb.Append(HexStringTable[b]);
                            });
                        }

                        sb.Append(";");
                    }

                    if (clientPacket != null)
                    {
                        sb.Append(string.Format("Time: {0};OpcodeType: CMSG;OpcodeValue: {1};Packet: ", secondsSinceEpoch, (ushort)clientPacket.Opcode));

                        if (clientPacket.Size - 2 != 0)
                        {
                            var data = clientPacket.Storage.ToList();

                            data.ForEach(b =>
                            {
                                sb.Append(HexStringTable[b]);
                            });
                        }

                        sb.Append(";");
                    }

                    string name = clientInfo.Replace(":", "_");

                    logWriter = TextWriter.Synchronized(File.AppendText(string.Format("Packet_{0}.dump", name)));
                    logWriter.WriteLine(sb.ToString());

                    logWriter.Flush();
                }
                finally
                {
                    logWriter.Close();
                }
            }
        }
开发者ID:mansemino,项目名称:Arctium,代码行数:59,代码来源:PacketLog.cs

示例2: Send

        public void Send(ref PacketWriter packet)
        {
            if (packet.Opcode == 0)
                return;

            var buffer = packet.ReadDataToSend();

            try
            {
                if (Crypt.IsInitialized)
                {
                    uint totalLength = (uint)packet.Size - 2;
                    totalLength <<= 13;
                    totalLength |= ((uint)packet.Opcode & 0x1FFF);

                    var header = BitConverter.GetBytes(totalLength);

                    Crypt.Encrypt(header);

                    buffer[0] = header[0];
                    buffer[1] = header[1];
                    buffer[2] = header[2];
                    buffer[3] = header[3];
                }

                clientSocket.Send(buffer, 0, buffer.Length, SocketFlags.None);

                string clientInfo = ((IPEndPoint)clientSocket.RemoteEndPoint).Address + ":" + ((IPEndPoint)clientSocket.RemoteEndPoint).Port;
                PacketLog.WritePacket(clientInfo, packet);

                packet.Flush();
            }
            catch (Exception ex)
            {
                Log.Message(LogType.Error, "{0}", ex.Message);
                Log.Message();

                clientSocket.Close();
            }
        }
开发者ID:Khiy,项目名称:Arctium-WoW,代码行数:40,代码来源:WorldClass.cs

示例3: WritePacket

        public static void WritePacket(string clientInfo, PacketWriter serverPacket = null, PacketReader clientPacket = null)
        {
            lock (syncObj)
            {
                try
                {
                    StringBuilder sb = new StringBuilder();

                    if (serverPacket != null)
                    {
                        sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Client: {0}", clientInfo));
                        sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Time: {0}", DateTime.Now.ToString()));

                        if (Enum.IsDefined(typeof(ServerMessage), serverPacket.Opcode))
                        {
                            sb.AppendLine("Type: ServerMessage");
                            sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Name: {0}", Enum.GetName(typeof(ServerMessage), serverPacket.Opcode)));
                        }

                        sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Value: 0x{0:X} ({1})", serverPacket.Opcode, serverPacket.Opcode));
                        sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Length: {0}", serverPacket.Size - 2));

                        sb.AppendLine("|----------------------------------------------------------------|");
                        sb.AppendLine("| 00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F |");
                        sb.AppendLine("|----------------------------------------------------------------|");
                        sb.Append("|");

                        if (serverPacket.Size - 2 != 0)
                        {
                            var data = serverPacket.ReadDataToSend().ToList();
                            data.RemoveRange(0, 4);

                            byte count = 0;
                            data.ForEach(b =>
                            {
                                if (b <= 0xF)
                                    sb.Append(String.Format(CultureInfo.InvariantCulture, " 0{0:X} ", b));
                                else
                                    sb.Append(String.Format(CultureInfo.InvariantCulture, " {0:X} ", b));

                                if (count == 15)
                                {
                                    sb.Append("|");
                                    sb.AppendLine();
                                    sb.Append("|");
                                    count = 0;
                                }
                                else
                                    count++;
                            });

                            sb.AppendLine("");
                            sb.AppendLine("|----------------------------------------------------------------|");
                        }

                        sb.AppendLine("");
                    }

                    if (clientPacket != null)
                    {
                        sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Client: {0}", clientInfo));
                        sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Time: {0}", DateTime.Now.ToString()));

                        sb.AppendLine("Type: ClientMessage");

                        if (Enum.IsDefined(typeof(ClientMessage), clientPacket.Opcode))
                            sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Name: {0}", clientPacket.Opcode));
                        else
                            sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Name: {0}", "Unknown"));

                        sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Value: 0x{0:X} ({1})", (ushort)clientPacket.Opcode, (ushort)clientPacket.Opcode));
                        sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "Length: {0}", clientPacket.Size));

                        sb.AppendLine("|----------------------------------------------------------------|");
                        sb.AppendLine("| 00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F |");
                        sb.AppendLine("|----------------------------------------------------------------|");
                        sb.Append("|");

                        if (clientPacket.Size - 2 != 0)
                        {
                            var data = clientPacket.Storage.ToList();

                            byte count = 0;
                            data.ForEach(b =>
                            {

                                if (b <= 0xF)
                                    sb.Append(String.Format(CultureInfo.InvariantCulture, " 0{0:X} ", b));
                                else
                                    sb.Append(String.Format(CultureInfo.InvariantCulture, " {0:X} ", b));

                                if (count == 15)
                                {
                                    sb.Append("|");
                                    sb.AppendLine();
                                    sb.Append("|");
                                    count = 0;
                                }
                                else
                                    count++;
//.........这里部分代码省略.........
开发者ID:xyin,项目名称:Arctium,代码行数:101,代码来源:PacketLog.cs

示例4: Send

        public void Send(PacketWriter packet)
        {
            if (packet == null)
                return;

            DataBuffer = packet.ReadDataToSend(true);

            try
            {
                clientSocket.Send(DataBuffer, DataBuffer.Length, SocketFlags.None);
                packet.Flush();
            }
            catch (SocketException ex)
            {
                Log.Message(LogType.ERROR, "{0}", ex.Message);
                Log.Message();

                clientSocket.Close();
            }
        }
开发者ID:ArkantosWoW,项目名称:ArkantosEmu,代码行数:20,代码来源:RealmClass.cs

示例5: HandleRealmList

        public void HandleRealmList(PacketReader data)
        {
            Log.Message(LogType.NORMAL, "RealmList");

            using (var realmData = new PacketWriter())
            {
                Realms.ToList().ForEach(r =>
                {
                    using (var result = DB.Characters.Select("SELECT COUNT(*) as Count FROM characters WHERE AccountId = ? AND RealmId = ?", account.Id, r.Value.Id))
                    {
                        var charCount = result.Read<byte>(0, "Count");

                        realmData.WriteUInt8(1);
                        realmData.WriteUInt8(0);
                        realmData.WriteUInt8(0);
                        realmData.WriteCString(r.Key);
                        realmData.WriteCString(r.Value.IP + ":" + r.Value.Port);
                        realmData.WriteFloat(0);
                        realmData.WriteUInt8(charCount);
                        realmData.WriteUInt8(1);
                        realmData.WriteUInt8(0x2C);
                    }
                });

                using (var realmList = new PacketWriter())
                {
                    realmList.WriteUInt8((byte)ClientLink.CMD_REALM_LIST);
                    realmList.WriteUInt16((ushort)(realmData.BaseStream.Length + 8));
                    realmList.WriteUInt32(0);
                    realmList.WriteUInt16((ushort)Realms.Count);
                    realmList.WriteBytes(realmData.ReadDataToSend());
                    realmList.WriteUInt8(0);
                    realmList.WriteUInt8(0x10);

                    Send(realmList);
                }
            }
        }
开发者ID:ArkantosWoW,项目名称:ArkantosEmu,代码行数:38,代码来源:RealmClass.cs

示例6: Send

        public async void Send(PacketWriter packet)
        {
            DataBuffer = packet.ReadDataToSend(true);

            try
            {
                DataWriter writer = new DataWriter(clientSocket.OutputStream);
                writer.WriteBytes(DataBuffer);

                await writer.StoreAsync();
                packet.Flush();
            }
            catch (Exception ex)
            {
                Log.Message(LogType.ERROR, "{0}", ex.Message);
                Log.Message();

                clientSocket.Dispose();
            }
        }
开发者ID:concept45,项目名称:Arctium-RT,代码行数:20,代码来源:RealmClass.cs

示例7: HandleRealmList

        public void HandleRealmList(RealmClass session, PacketReader data)
        {
            Log.Message(LogType.NORMAL, "RealmList");

            PacketWriter realmData = new PacketWriter();

            foreach (var r in Realms)
            {
                realmData.WriteUInt8(1);
                realmData.WriteUInt8(0);
                realmData.WriteUInt8(0);
                realmData.WriteCString(r.Name);
                realmData.WriteCString(r.IP + ":" + r.Port);
                realmData.WriteFloat(0);
                realmData.WriteUInt8(0);  // CharCount
                realmData.WriteUInt8(1);
                realmData.WriteUInt8(0x2C);
            }

            PacketWriter realmList = new PacketWriter();
            realmList.WriteUInt8((byte)ClientLink.CMD_REALM_LIST);
            realmList.WriteUInt16((ushort)(realmData.BaseStream.Length + 8));
            realmList.WriteUInt32(0);
            realmList.WriteUInt16((ushort)Realms.Count);
            realmList.WriteBytes(realmData.ReadDataToSend());
            realmList.WriteUInt8(0);
            realmList.WriteUInt8(0x10);

            session.Send(realmList);
        }
开发者ID:concept45,项目名称:Arctium-RT,代码行数:30,代码来源:RealmClass.cs

示例8: WritePacket

        public static async void WritePacket(string clientInfo, PacketWriter serverPacket = null, PacketReader clientPacket = null)
        {
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFile logFile = await localFolder.CreateFileAsync("Packet.log", CreationCollisionOption.OpenIfExists);
            StringBuilder outPut = new StringBuilder();

            if (serverPacket != null)
            {
                outPut.AppendLine(String.Format("Client: {0}", clientInfo));

                if (Enum.IsDefined(typeof(LegacyMessage), serverPacket.Opcode))
                {
                    outPut.AppendLine("Type: LegacyMessage");
                    outPut.AppendLine(String.Format("Name: {0}", Enum.GetName(typeof(LegacyMessage), serverPacket.Opcode)));
                }
                else if (Enum.IsDefined(typeof(JAMCMessage), serverPacket.Opcode))
                {
                    outPut.AppendLine("Type: JAMCMessage");
                    outPut.AppendLine(String.Format("Name: {0}", Enum.GetName(typeof(JAMCMessage), serverPacket.Opcode)));
                }
                else if (Enum.IsDefined(typeof(Message), serverPacket.Opcode))
                {
                    outPut.AppendLine("Type: Message");
                    outPut.AppendLine(String.Format("Name: {0}", Enum.GetName(typeof(Message), serverPacket.Opcode)));
                }
                else
                {
                    outPut.AppendLine("Type: JAMCCMessage");
                    outPut.AppendLine(String.Format("Name: {0}", Enum.GetName(typeof(JAMCCMessage), serverPacket.Opcode)));
                }

                outPut.AppendLine(String.Format("Value: 0x{0:X} ({1})", serverPacket.Opcode, serverPacket.Opcode));
                outPut.AppendLine(String.Format("Length: {0}", serverPacket.Size - 2));

                outPut.AppendLine("|----------------------------------------------------------------|");
                outPut.AppendLine("| 00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F |");
                outPut.AppendLine("|----------------------------------------------------------------|");
                outPut.Append("|");

                if (serverPacket.Size - 2 != 0)
                {
                    var data = serverPacket.ReadDataToSend().ToList();
                    data.RemoveRange(0, 4);

                    byte count = 0;
                    foreach (var b in data)
                    {
                        if (b <= 0xF)
                            outPut.Append(String.Format(" 0{0:X} ", b));
                        else
                            outPut.Append(String.Format(" {0:X} ", b));

                        if (count == 15)
                        {
                            outPut.Append("|");
                            outPut.AppendLine();
                            outPut.Append("|");
                            count = 0;
                        }
                        else
                            count++;
                    }

                    outPut.AppendLine("");
                    outPut.AppendLine("|----------------------------------------------------------------|");
                }

                outPut.AppendLine("");
                outPut.AppendLine("");
            }

            if (clientPacket != null)
            {
                outPut.AppendLine(String.Format("Client: {0}", clientInfo));
                outPut.AppendLine("Type: ClientMessage");

                if (Enum.IsDefined(typeof(ClientMessage), clientPacket.Opcode))
                    outPut.AppendLine(String.Format("Name: {0}", clientPacket.Opcode));
                else
                    outPut.AppendLine(String.Format("Name: {0}", "Unknown"));

                outPut.AppendLine(String.Format("Value: 0x{0:X} ({1})", (ushort)clientPacket.Opcode, (ushort)clientPacket.Opcode));
                outPut.AppendLine(String.Format("Length: {0}", clientPacket.Size));

                outPut.AppendLine("|----------------------------------------------------------------|");
                outPut.AppendLine("| 00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F |");
                outPut.AppendLine("|----------------------------------------------------------------|");
                outPut.Append("|");

                if (clientPacket.Size - 2 != 0)
                {
                    var data = clientPacket.Storage.ToList();

                    byte count = 0;
                    foreach (var b in data)
                    {

                        if (b <= 0xF)
                            outPut.Append(String.Format(" 0{0:X} ", b));
                        else
//.........这里部分代码省略.........
开发者ID:concept45,项目名称:Arctium-RT,代码行数:101,代码来源:PacketLog.cs

示例9: Send

        public void Send(PacketWriter packet)
        {
            DataBuffer = packet.ReadDataToSend(true);

            try
            {
                clientSocket.BeginSend(DataBuffer, 0, DataBuffer.Length, SocketFlags.None, new AsyncCallback(FinishSend), clientSocket);
                packet.Flush();
            }
            catch (Exception ex)
            {
                Log.Message(LogType.ERROR, "{0}", ex.Message);
                Log.Message();
                clientSocket.Close();
            }
        }
开发者ID:boredtodeath,项目名称:Arctium,代码行数:16,代码来源:RealmClass.cs

示例10: WritePacket

        public static void WritePacket(string clientInfo, PacketWriter serverPacket = null, PacketReader clientPacket = null)
        {
            using (StreamWriter logWriter = File.AppendText("Packet.log"))
            {
                if (serverPacket != null)
                {
                    logWriter.WriteLine(String.Format("Client: {0}", clientInfo));

                    if (Enum.IsDefined(typeof(LegacyMessage), serverPacket.Opcode))
                    {
                        logWriter.WriteLine("Type: LegacyMessage");
                        logWriter.WriteLine(String.Format("Name: {0}", Enum.GetName(typeof(LegacyMessage), serverPacket.Opcode)));
                    }
                    else if (Enum.IsDefined(typeof(JAMCMessage), serverPacket.Opcode))
                    {
                        logWriter.WriteLine("Type: JAMCMessage");
                        logWriter.WriteLine(String.Format("Name: {0}", Enum.GetName(typeof(JAMCMessage), serverPacket.Opcode)));
                    }
                    else if (Enum.IsDefined(typeof(Message), serverPacket.Opcode))
                    {
                        logWriter.WriteLine("Type: Message");
                        logWriter.WriteLine(String.Format("Name: {0}", Enum.GetName(typeof(Message), serverPacket.Opcode)));
                    }
                    else
                    {
                        logWriter.WriteLine("Type: JAMCCMessage");
                        logWriter.WriteLine(String.Format("Name: {0}", Enum.GetName(typeof(JAMCCMessage), serverPacket.Opcode)));
                    }

                    logWriter.WriteLine(String.Format("Value: 0x{0:X} ({1})", serverPacket.Opcode, serverPacket.Opcode));
                    logWriter.WriteLine(String.Format("Length: {0}", serverPacket.Size - 2));

                    logWriter.WriteLine("|----------------------------------------------------------------|");
                    logWriter.WriteLine("| 00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F |");
                    logWriter.WriteLine("|----------------------------------------------------------------|");
                    logWriter.Write("|");

                    if (serverPacket.Size - 2 != 0)
                    {
                        var data = serverPacket.ReadDataToSend().ToList();
                        data.RemoveRange(0, 4);

                        byte count = 0;
                        data.ForEach(b =>
                        {
                            if (b <= 0xF)
                                logWriter.Write(String.Format(" 0{0:X} ", b));
                            else
                                logWriter.Write(String.Format(" {0:X} ", b));

                            if (count == 15)
                            {
                                logWriter.Write("|");
                                logWriter.WriteLine();
                                logWriter.Write("|");
                                count = 0;
                            }
                            else
                                count++;
                        });

                        logWriter.WriteLine("");
                        logWriter.WriteLine("|----------------------------------------------------------------|");
                    }

                    logWriter.WriteLine("");
                    logWriter.WriteLine("");

                    logWriter.Close();
                }

                if (clientPacket != null)
                {
                    logWriter.WriteLine(String.Format("Client: {0}", clientInfo));
                    logWriter.WriteLine("Type: ClientMessage");

                    if (Enum.IsDefined(typeof(ClientMessage), clientPacket.Opcode))
                        logWriter.WriteLine(String.Format("Name: {0}", clientPacket.Opcode));
                    else
                        logWriter.WriteLine(String.Format("Name: {0}", "Unknown"));

                    logWriter.WriteLine(String.Format("Value: 0x{0:X} ({1})", (ushort)clientPacket.Opcode, (ushort)clientPacket.Opcode));
                    logWriter.WriteLine(String.Format("Length: {0}", clientPacket.Size));

                    logWriter.WriteLine("|----------------------------------------------------------------|");
                    logWriter.WriteLine("| 00  01  02  03  04  05  06  07  08  09  0A  0B  0C  0D  0E  0F |");
                    logWriter.WriteLine("|----------------------------------------------------------------|");
                    logWriter.Write("|");

                    if (clientPacket.Size - 2 != 0)
                    {
                        var data = clientPacket.Storage.ToList();

                        byte count = 0;
                        data.ForEach(b =>
                        {

                            if (b <= 0xF)
                                logWriter.Write(String.Format(" 0{0:X} ", b));
                            else
//.........这里部分代码省略.........
开发者ID:Gargash,项目名称:Arctium,代码行数:101,代码来源:PacketLog.cs


注:本文中的Framework.Network.Packets.PacketWriter.ReadDataToSend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。