本文整理汇总了C#中PacketHandler类的典型用法代码示例。如果您正苦于以下问题:C# PacketHandler类的具体用法?C# PacketHandler怎么用?C# PacketHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PacketHandler类属于命名空间,在下文中一共展示了PacketHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterHandler
public static void RegisterHandler(PacketId packetId, PacketHandler handler)
{
if (packetHandlers.ContainsKey(packetId))
throw new Exception("Duplicate packet handler");
packetHandlers[packetId] = handler;
}
示例2: MinecraftClient
public MinecraftClient(Session session)
{
Session = session;
PacketQueue = new ConcurrentQueue<IPacket>();
PacketHandlers = new PacketHandler[256];
Handlers.PacketHandlers.Register(this);
}
示例3: Initialize
public static void Initialize()
{
m_LHandlers = new PacketHandler<LoginConnection>[0x20];
levels = new Dictionary<int, PacketHandler<ClientConnection>[]>();
RegisterDelegates();
}
示例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;
}
示例5: Initialize
public static void Initialize()
{
m_GHandlers = new PacketHandler<GameConnection>[0x20];
m_LHandlers = new PacketHandler<ArcheAgeConnection>[0x30];
Registration();
}
示例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();
}
示例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 );
}
示例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);
}
示例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();
}
示例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 });
}
}
示例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>();
}
示例12: RegisterHandler
public bool RegisterHandler(UInt32 id, PacketHandler handler)
{
if (true == FHandlers.ContainsKey(id))
{
return false;
}
FHandlers[id] = handler;
return true;
}
示例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;
}
示例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, )
}
示例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));
}