void ProcessPackets() { while (IsConnected) { try { MCForge.Networking.Packet packet = PacketQueue.InQueue.Dequeue(); // PacketEventArgs args = new PacketEventArgs(packet.WritePacket(), true, ) switch (packet.PacketID) { case PacketIDs.Identification: ProcessLogin(packet as PacketIdentification); break; case PacketIDs.PlayerSetBlock: ProcessBlockChange(packet as PacketPlayerSetBlock); break; case PacketIDs.PosAndRot: ProcessPosAndRot(packet as PacketPositionAndOrientation); break; case PacketIDs.Message: ProcessMessage(packet as PacketMessage); break; } } catch { break; } } PacketQueue.CloseConnection(); }
/// <summary> /// Kicks the player with the specified reason. /// </summary> /// <param name="reason">The reason.</param> public void Kick(string reason) { IsBeingKicked = true; PacketQueue.WritePacketNowAndFlush(new PacketDisconnectPlayer(0xFF, reason)); PacketQueue.Stop(); PacketQueue.CloseConnection(); Dispose(); }