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


C# IConnection.PushPacket方法代码示例

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


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

示例1: Send

        public void Send(IConnection state)
        {
            if (state == null || !state.IsValid)
                return;

            if (!OuterNetworkOpcode.Send.ContainsKey(GetType()))
            {
                Log.Warn("UNKNOWN packet opcode: {0}", GetType().Name);
                return;
            }

            lock (WriteLock)
            {
                if (Data == null)
                {
                    try
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            using (BinaryWriter writer = new BinaryWriter(stream, new UTF8Encoding()))
                            {
                                WriteH(writer, OuterNetworkOpcode.Send[GetType()]);
                                WriteH(writer, 0); //Reserved for length
                                Write(writer);
                            }

                            Data = stream.ToArray();
                            BitConverter.GetBytes((short)Data.Length).CopyTo(Data, 2);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Warn("Can't write packet: {0}", GetType().Name);
                        Log.WarnException("ASendPacket", ex);
                        return;
                    }
                }
            }

            //Log.Warn("PUSH packet opcode: {0}", GetType().Name);
            //Log.Debug("Data:\n{0}", Data.FormatHex());
            state.PushPacket(Data);
        }
开发者ID:mMellowz,项目名称:revcore,代码行数:43,代码来源:OuterNetworkSendPacket.cs

示例2: Send

        public void Send(IConnection state)
        {
            if (state == null || !state.IsValid)
            { return; }

            if (!OpCodes.Send.ContainsKey(GetType()))
            {
                Logger.WriteLine(LogState.Warn,"UNKNOWN packet opcode: {0}", GetType().Name);
                return;
            }


            lock (WriteLock)
            {
                if (Datas == null)
                {
                    try
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            using (BinaryWriter writer = new BinaryWriter(stream, new UTF8Encoding()))
                            {
                                WriteWord(writer, 0); //Reserved for length
                                WriteWord(writer, OpCodes.Send[GetType()]);
                                Write(writer);
                            }

                            Datas = stream.ToArray();
                            BitConverter.GetBytes((short) Datas.Length).CopyTo(Datas, 0);
                            Logger.WriteLine(LogState.Debug, "S->C Packet Data:\n{0}", Datas.FormatHex());
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine(LogState.Warn,"Can't write packet: {0}", GetType().Name);
                        Logger.WriteLine(LogState.Warn, "ASendPacket" + ex);
                        return;
                    }
                }
            }

            state.PushPacket(Datas);
        }
开发者ID:arkanoid1,项目名称:Temu,代码行数:43,代码来源:ASendPacket.cs

示例3: Send

 public void Send(IConnection state)
 {
     Log.Debug("SendPacket Data:\n{0}", Data.FormatHex());
     state.PushPacket(Data);
 }
开发者ID:prestanneth,项目名称:TeraEmulator_1725,代码行数:5,代码来源:SendPacket.cs

示例4: Send

 public void Send(IConnection state)
 {
     state.PushPacket(Data);
 }
开发者ID:r4ymonf,项目名称:TeraEmulator,代码行数:4,代码来源:SpTest.cs

示例5: Send

 public void Send(IConnection state)
 {
     Logger.WriteLine(LogState.Debug,"SendPacket Data:\n{0}", Data.FormatHex());
     state.PushPacket(Data);
 }
开发者ID:arkanoid1,项目名称:Temu,代码行数:5,代码来源:SendPacket.cs

示例6: Send

        public void Send(IConnection state)
        {
            if (state == null || !state.IsValid)
                return;

            State = (OuterNetworkConnection)state;

            if (GetType() != typeof(SpTest) && !OuterNetworkOpcode.Send.ContainsKey(GetType()))
            {
                Log.Warn("UNKNOWN packet opcode: {0}", GetType().Name);
                return;
            }

            lock (WriteLock)
            {
                if (Datas == null)
                {
                    try
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            int lengthoffset = 6;

                            using (BinaryWriter writer = new BinaryWriter(stream))
                            {
                                WriteH(writer, 0); //Reserved for packet length

                                switch (WorldServer.CountryCode)
                                {
                                    case CountryCode.CN:
                                        {
                                            WriteC(writer, 0);
                                            lengthoffset = 7;
                                        }
                                        break;
                                    case CountryCode.EN:
                                        {
                                            lengthoffset = 6;
                                        }
                                        break;
                                    case CountryCode.TH:
                                        {
                                            lengthoffset = 6;
                                        }
                                        break;
                                    case CountryCode.TW:
                                        {
                                            WriteC(writer, 0);
                                            lengthoffset = 7;
                                        }
                                        break;
                                }

                                WriteH(writer, State.UID);
                                WriteH(writer, (GetType() != typeof(SpTest)) ? OuterNetworkOpcode.Send[GetType()] : 0);
                                WriteH(writer, 0); //Reserved for data length
                                Write(writer);
                            }
                            Datas = stream.ToArray();
                            BitConverter.GetBytes((short)(Datas.Length - 2)).CopyTo(Datas, 0);
                            BitConverter.GetBytes((short)(Datas.Length - 8)).CopyTo(Datas, lengthoffset);

                            //Log.Debug("Send Data {0}: [{1}] {2}", GetType().Name, Datas.Length, Datas.FormatHex());

                            WriteScope(ref Datas);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Warn("Can't write packet: {0}", GetType().Name);
                        Log.WarnException("ASendPacket", ex);
                        return;
                    }
                }
            }

            state.PushPacket(Datas);
        }
开发者ID:mMellowz,项目名称:revcore,代码行数:78,代码来源:OuterNetworkSendPacket.cs


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