• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PacketHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PacketHandler的典型用法代码示例。如果您正苦于以下问题:C# PacketHandler类的具体用法?C# PacketHandler怎么用?C# PacketHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PacketHandler类属于命名空间,在下文中一共展示了PacketHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RegisterHandler

        public static void RegisterHandler(PacketId packetId, PacketHandler handler)
        {
            if (packetHandlers.ContainsKey(packetId))
                throw new Exception("Duplicate packet handler");

            packetHandlers[packetId] = handler;
        }
开发者ID:Rohansi,项目名称:Programe,代码行数:7,代码来源:Packet.Static.cs


示例2: MinecraftClient

 public MinecraftClient(Session session)
 {
     Session = session;
     PacketQueue = new ConcurrentQueue<IPacket>();
     PacketHandlers = new PacketHandler[256];
     Handlers.PacketHandlers.Register(this);
 }
开发者ID:nevercast,项目名称:Craft.Net,代码行数:7,代码来源:MinecraftClient.cs


示例3: Initialize

        public static void Initialize()
        {
            m_LHandlers = new PacketHandler<LoginConnection>[0x20];
            levels = new Dictionary<int, PacketHandler<ClientConnection>[]>();

            RegisterDelegates();
        }
开发者ID:ExpTeam,项目名称:trunk,代码行数:7,代码来源:DelegateList.cs


示例4: OnBlockChange

        public PacketHandler OnBlockChange(PacketType p_type, string CustomPacketType, ref PacketReader _pReader, PacketHandler packet, ref ClientManager _client)
        {
            PlayerBlockPlacementPacket _p = (PlayerBlockPlacementPacket)packet;
            BlockChangePacket block_change = new BlockChangePacket(PacketType.BlockChange);
            block_change.Metadata = Utils.GetMetadata(_p.BlockID.s_short, _p.Direction, _client.id);
            //block_change.Metadata = 0x00;
            int X = _p.X;
            byte Y = _p.Y;
            int Z = _p.Z;
            int index = 0;
            int temp = (_p.Direction == 0 ? Y-- :
                (_p.Direction == 1 ? Y++ :
                (_p.Direction == 2 ? Z-- :
                (_p.Direction == 3 ? Z++ :
                (_p.Direction == 4 ? X-- : X++)))));

            if (_p.BlockID.s_short > 255)
            {
                //SendBlockChange(block_change, ref _client, ref _pReader, _p, true);

            }
            else//This is a item ID
            {
                SendBlockChange(block_change, ref _client, ref _pReader, _p, true);
            }
            return block_change;
        }
开发者ID:ultimakaz,项目名称:lib-open-craft,代码行数:27,代码来源:BlockChange.cs


示例5: Initialize

        public static void Initialize()
        {
            m_GHandlers = new PacketHandler<GameConnection>[0x20];
            m_LHandlers = new PacketHandler<ArcheAgeConnection>[0x30];

            Registration();
        }
开发者ID:ExpTeam,项目名称:trunk,代码行数:7,代码来源:PacketList.cs


示例6: Server

		/// <summary>
		/// Constructor
		/// </summary>
		public Server()
		{
            m_disposed = false;
            m_handler = PacketHandler.Instatinate();
            m_thread = new Thread(new ThreadStart(AcceptThread));
            m_thread.Name = "UOExt server thread";
            m_thread.Start();
		}
开发者ID:WildGenie,项目名称:uo-ext,代码行数:11,代码来源:Server.cs


示例7: Configure

		public static void Configure()
		{
			m_Real6C = PacketHandlers.GetHandler( 0x6C );
			m_LastTarget = new Hashtable();

			PacketHandlers.Register( 0x6C, 19, true, new OnPacketReceive( TargetResponse ) );
			EventSink.Disconnected += new DisconnectedEventHandler( EventSink_Disconnected );
		}
开发者ID:greeduomacro,项目名称:GoUO,代码行数:8,代码来源:EasyUO.cs


示例8: ReliableUDPConnection

 public ReliableUDPConnection(UdpClient sender, IPEndPoint destinationep, UInt32 cid, Connection owner)
 {
     DestinationEP = destinationep;
     ConnectionID = cid;
     Sender = sender;
     Sent = new Dictionary<UInt32,UDPPacket>();
     Owner = owner;
     Received = new HashSet<UInt32>();
     OnPacketRecv += new PacketHandler(RegisterPacket);
     OnPacketRecv += new PacketHandler(OnPacket);
 }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:11,代码来源:ReliableUDPConnection.cs


示例9: BidirectionalStream

        public BidirectionalStream(NetworkReader from, NetworkWriter to, PacketHandler packetHandler)
        {
            reader = from;
            writer = to;

            handler = packetHandler;

            var rStart = new ThreadStart(Run);
            readerThread = new Thread(rStart);
            readerThread.Start();
        }
开发者ID:RobotCaleb,项目名称:uberminer,代码行数:11,代码来源:BidirectionalStream.cs


示例10: Program

        public Program()
        {
            try
            {
                _handler = new PacketHandler("127.0.0.1", 25565, HandlerMode.Client);
            }
            catch (SocketException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadKey();
                Environment.Exit(1);
            }

            _loginResponse = Login();

            // Subscribe packets
            _handler.Subscribe(Packet.Handshake, ShakeHands);

            _handler.Subscribe(Packet.Login, p =>
                                                 {
                                                     var packet = (LoginResponse) p;
                                                     Console.WriteLine("Entity ID: " + packet.EntityId);
                                                     Console.WriteLine("Map seed: " + packet.MapSeed);
                                                 });

            _handler.UnsubscribedPacket += p => { };
            _handler.Subscribe(Packet.Disconnect, p =>
                                                      {
                                                          Console.Write("You were kicked: " + ((Disconnect) p).Reason);
                                                          _handler.Disconnect();
                                                      });

            _handler.Subscribe(Packet.ChatMessage, p => Console.WriteLine(((ChatMessage)p).Message));
            _handler.EventMode = true;

            // START ACTION

            // This starts the server joining chain of packets
            _handler.SendPacket(new Handshake { Username = _username });

            while (_handler.IsActive)
            {
                var line = Console.ReadLine();
                if (line == "exit")
                {
                    _handler.SendPacket(new Disconnect {Reason = "This is ignored anyways, so eh"});

                    _handler.Disconnect();
                    break;
                }

                _handler.SendPacket(new ChatMessage { Message = line });
            }
        }
开发者ID:pollyzoid,项目名称:sharpcraft,代码行数:54,代码来源:SharpCraft.cs


示例11: MinecraftServer

 public MinecraftServer()
 {
     LogicHelpers.Register();
     PacketHandlers = new PacketHandler[256];
     Handlers.PacketHandlers.RegisterHandlers(this);
     NetworkLock = new object();
     Clients = new List<RemoteClient>();
     Settings = ServerSettings.DefaultSettings;
     EntityManager = new EntityManager(this);
     LastTimeUpdate = DateTime.MinValue;
     NextChunkUpdate = DateTime.MinValue;
     PhysicsEngines = new List<PhysicsEngine>();
 }
开发者ID:nevercast,项目名称:Craft.Net,代码行数:13,代码来源:MinecraftServer.cs


示例12: RegisterHandler

            public bool RegisterHandler(UInt32 id, PacketHandler handler)
            {
                if (true == FHandlers.ContainsKey(id))
                {

                    return false;

                }

                FHandlers[id] = handler;

                return true;
            }
开发者ID:lythm,项目名称:orb3d,代码行数:13,代码来源:GSSessionPacketHandler.cs


示例13: OnSpwanPositionHandler

 //NO LONGER NEEDED.
 public PacketHandler OnSpwanPositionHandler(PacketType p_type, string CustomPacketType, ref PacketReader _pReader, PacketHandler _p, ref ClientManager cm)
 {
     SpawnPlayerPacket p = new SpawnPlayerPacket(PacketType.SpwanPosition);
     p.X = cm._player.position.X;
     p.Y = cm._player.position.Z;
     p.Z = cm._player.position.Y;
     p.BuildPacket();
     cm.SendPacket(p, cm.id, ref cm, false, false);
     int i = 0;
     for (; i < base.ModuleAddons.Count; i++)
     {
         base.ModuleAddons.ElementAt(i).Value(PacketType.SpwanPosition, ModuleAddons.ElementAt(i).Key, ref _pReader, (PacketHandler)p, ref cm);
     }
     p = null;
     return _p;
 }
开发者ID:ultimakaz,项目名称:lib-open-craft,代码行数:17,代码来源:SpawnPlayer.cs


示例14: RegisterHandlers

        internal static void RegisterHandlers(object source, ConnectionEventArgs args)
        {
            PacketHandler PRequestSubscriptionData = new PacketHandler(Process_RequestSubscriptionData);
            //PacketHandler P = new PacketHandler(Process_);
            //PacketHandler P = new PacketHandler(Process_);
            //PacketHandler P = new PacketHandler(Process_);
            //PacketHandler P = new PacketHandler(Process_);
            //PacketHandler P = new PacketHandler(Process_);
            //PacketHandler P = new PacketHandler(Process_);

            (source as IonTcpConnection).
                AddHandler(26, PacketHandlerPriority.DefaultAction, PRequestSubscriptionData);
                //AddHandler(, PacketHandlerPriority.DefaultAction, ).
                //AddHandler(, PacketHandlerPriority.DefaultAction, ).
                //AddHandler(, PacketHandlerPriority.DefaultAction, ).
                //AddHandler(, PacketHandlerPriority.DefaultAction, ).
                //AddHandler(, PacketHandlerPriority.DefaultAction, )
        }
开发者ID:habb0,项目名称:-IHI-Subscription,代码行数:18,代码来源:PacketHandlers.cs


示例15: Initialize

        public static void Initialize()
        {
            m_Target = PacketHandlers.GetHandler(0x6C);
            m_Target6017 = PacketHandlers.Get6017Handler(0x6C);

            m_Equip = PacketHandlers.GetHandler(0x13);
            m_Equip6017 = PacketHandlers.Get6017Handler(0x13);

            if (m_Target6017 == null)
                m_Target6017 = m_Target;

            if (m_Equip6017 == null)
                m_Equip6017 = m_Equip;

            PacketHandlers.Register(0x6C, 19, true, new OnPacketReceive(TargetResponse));
            PacketHandlers.Register6017(0x6C, 19, true, new OnPacketReceive(TargetResponse6017));
            PacketHandlers.Register(0x13, 10, true, new OnPacketReceive(EquipReq));
            PacketHandlers.Register6017(0x13, 10, true, new OnPacketReceive(EquipReq6017));
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:19,代码来源:Sync.cs


示例16: PAGE_Add

        internal void PAGE_Add(HttpListenerContext Context)
        {
            if (Context.Request.IsLocal)
            {
                string Header = Context.Request.QueryString["header"];

                uint HeaderID = 0;

                if (!uint.TryParse(Header, out HeaderID))
                    HeaderID = Base64Encoding.DecodeUInt32(Encoding.UTF8.GetBytes(Header));

                PacketHandler Handler = new PacketHandler(Process_DYNAMIC);
                lock(this.fHandlers)
                    fHandlers.Add(HeaderID, Handler);
                RegisterHandlersToExisting(HeaderID, Handler);

                Context.Response.Redirect("addform");
                Context.Response.Close();
            }
        }
开发者ID:Cecer1,项目名称:-IHI-PacketDebugger,代码行数:20,代码来源:Handlers.cs


示例17: Peer

        /// <summary>Constructor</summary>
        /// <param name="client">Client socket with connected client</param>
        /// <param name="ip">Client ip</param>
        /// <param name="port">Server port</param>
        public Peer(Socket client, Server server, PacketHandler handler)
        {
            m_disposed = false;
            m_socket = client;
            m_server = server;
            m_buffer = new byte[65536 * 2];
            m_sendBuffer = new byte[65536 * 2];
            m_bufferPointer = 0;
            m_handler = handler;
            m_connected = true;
            m_AsyncSend = new AsyncCallback(OnSend);
            m_AsyncRecive = new AsyncCallback(OnRecive);
            m_sending = false;
            m_chunkSended = new AutoResetEvent(false);

            m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 65536 * 2); // this should be enough for every packet
            m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, 65536 * 2);
            m_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, 1);
            m_socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1);

            BeginReceive();
        }
开发者ID:WildGenie,项目名称:uo-ext,代码行数:26,代码来源:Peer.cs


示例18: UOExtInitialize

        public override void UOExtInitialize(PacketHandler hndlr)
        {
            m_libraryList = new LibraryList();
            m_pluginsList = new PluginsList();
            m_initComplete = new InitializationComplete();

            hndlr.RegisterPacketHandler(0x00, 0, new OnPacketRecive(UOExtPacket));

            for (short i = 0; i < Dll.Dlls.Length; i++)
            {
                Dll.Dlls[i].Header = new DllHeader(Dll.Dlls[i], i);
                uint offset = (uint)(Dll.Dlls[i].Header.DllSize);
                do
                {
                    DllContent dc = new DllContent(Dll.Dlls[i], offset);
                    offset += (uint)dc.DllChunkSize;
                    Dll.Dlls[i].Content.Enqueue(dc);
                } while (offset < Dll.Dlls[i].Size);
            }
            Dll.UOExt = new Dll(Config.UOExtPath, true);
            Dll.UOExtGUI = new Dll(Config.UOExtGUIPath, true);
        }
开发者ID:WildGenie,项目名称:uo-ext,代码行数:22,代码来源:Core.cs


示例19: RemoteClient

        public RemoteClient(IMultiplayerServer server, IPacketReader packetReader, PacketHandler[] packetHandlers, Socket connection)
        {
            LoadedChunks = new List<Coordinates2D>();
            Server = server;
            Inventory = new InventoryWindow(server.CraftingRepository);
            InventoryWindow.WindowChange += HandleWindowChange;
            SelectedSlot = InventoryWindow.HotbarIndex;
            CurrentWindow = InventoryWindow;
            ItemStaging = ItemStack.EmptyStack;
            KnownEntities = new List<IEntity>();
            Disconnected = false;
            EnableLogging = server.EnableClientLogging;
            NextWindowID = 1;
            Connection = connection;
            SocketPool = new SocketAsyncEventArgsPool(100, 200, 65536);
            PacketReader = packetReader;
            PacketHandlers = packetHandlers;

            cancel = new CancellationTokenSource();

            StartReceive();
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:22,代码来源:RemoteClient.cs


示例20: RegisterPacketHandler

 public void RegisterPacketHandler( char packetcode, PacketHandler packethandler )
 {
     if( packethandlers.Contains( packetcode ) && (PacketHandler)packethandlers[ packetcode ] != packethandler )
     {
         throw new Exception( "Trying to register duplicate packetcode " + packetcode.ToString() + " by handler " + packethandler.ToString() + " conflicting handler: " + packethandlers[ packetcode ].ToString() );
     }
     if( !packethandlers.Contains( packetcode ) )
     {
         packethandlers.Add( packetcode, packethandler );
     }
 }
开发者ID:hughperkins,项目名称:osmp-cs,代码行数:11,代码来源:NetworkLevel2Connection.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PacketIn类代码示例发布时间:2022-05-24
下一篇:
C# PacketDirection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap