public static void Handle(byte[] buffer) { var packetId = BitConverter.ToUInt16(buffer, 4); if (Global.Verbose) { FConsole.WriteLine($"Got Packet {packetId}"); } switch (packetId) { case 1000: Login.Handle(buffer); break; case 1001: Walk.Handle(buffer); break; case 1002: Ping.Handle(buffer); break; case 1003: Spawn.Handle(buffer); break; } ArrayPool <byte> .Shared.Return(buffer); }
public static void Handle(NetworkClient socket, byte[] buffer) { var packetId = BitConverter.ToUInt16(buffer, 4); var player = socket.Player; switch (packetId) { case 1000: { Login.Handle(player, buffer); break; } case 1001: { Walk.Handle(player, buffer); break; } case 1002: { Ping.Handle(player, buffer); break; } } }
/// <summary> /// Handles a change in PlayerKeyState. /// </summary> /// <param name="sender">Sender of the event.</param> /// <param name="e">Object containing information about the event.</param> public void Handle(object sender, KeyStateChangedEventArgs e) { if (Action != null && _check(e, Keys.Action)) { Action.Handle(sender, e); } if (Crouch != null && _check(e, Keys.Crouch)) { Crouch.Handle(sender, e); } if (Fire != null && _check(e, Keys.Fire)) { Fire.Handle(sender, e); } if (Sprint != null && _check(e, Keys.Sprint)) { Sprint.Handle(sender, e); } if (SecondaryAttack != null && _check(e, Keys.SecondaryAttack)) { SecondaryAttack.Handle(sender, e); } if (Jump != null && _check(e, Keys.Jump)) { Jump.Handle(sender, e); } if (LookRight != null && _check(e, Keys.LookRight)) { LookRight.Handle(sender, e); } if (Handbrake != null && _check(e, Keys.Handbrake)) { Handbrake.Handle(sender, e); } if (Aim != null && _check(e, Keys.Aim)) { Aim.Handle(sender, e); } if (LookLeft != null && _check(e, Keys.LookLeft)) { LookLeft.Handle(sender, e); } if (Submission != null && _check(e, Keys.Submission)) { Submission.Handle(sender, e); } if (Walk != null && _check(e, Keys.Walk)) { Walk.Handle(sender, e); } if (AnalogUp != null && _check(e, Keys.AnalogUp)) { AnalogUp.Handle(sender, e); } if (AnalogDown != null && _check(e, Keys.AnalogDown)) { AnalogDown.Handle(sender, e); } if (AnalogLeft != null && _check(e, Keys.AnalogLeft)) { AnalogLeft.Handle(sender, e); } if (AnalogRight != null && _check(e, Keys.AnalogRight)) { AnalogRight.Handle(sender, e); } if (Yes != null && _check(e, Keys.Yes)) { Yes.Handle(sender, e); } if (No != null && _check(e, Keys.No)) { No.Handle(sender, e); } if (CtrlBack != null && _check(e, Keys.CtrlBack)) { CtrlBack.Handle(sender, e); } }