/// <summary> /// Handles a packet using the correct queue /// </summary> /// <param name="packet">The packet that needs to be processed</param> public void handlePacket(ClientIncomingPacket packet) { PacketRegistery<ClientOpCode, ClientIncomingPacket>.handlePacket handeler = immidiateHandeler.getHandeler(packet.Opcode); if (handeler != null) handeler.Invoke(packet); else { lock (packetQueue.SyncRoot) { packetQueue.Enqueue(packet); } } }
static void ClientReceivedVersion(ClientIncomingPacket packet) { Console.WriteLine("Got version request packet from server!"); }
private void buildRemainingPacket() { if (buffer.Length < this.currentLengthOfPacket) // Wait for more data... throw new BufferUnderflowException("Not enought data in the buffer, we need to wait for more!"); byte[] packetData = new byte[this.currentLengthOfPacket]; Array.Copy(buffer, packetData, packetData.Length); if (buffer.Length == this.currentLengthOfPacket) buffer = null; else { byte[] byteBuffer = new byte[buffer.Length - this.currentLengthOfPacket]; Array.Copy(this.buffer, this.currentLengthOfPacket, byteBuffer, 0, byteBuffer.Length); buffer = byteBuffer; } currentLengthOfPacket = -1; ClientIncomingPacket incomingPacket; // Create new packet incomingPacket = new ClientIncomingPacket(packetData); // use C# events to tell every-one that there was a new packet //Console.WriteLine("Received packet " + incomingPacket.Opcode); if (packetArrival != null) packetArrival.Invoke(incomingPacket); }
/// <summary> /// Called when a packet has been received /// </summary> /// <param name="packet"></param> private void packetArrival(ClientIncomingPacket packet) { processor.handlePacket(packet); }
private void packetParser_packetArrival(ClientIncomingPacket packet) { if (this.packetArrival != null) this.packetArrival.Invoke(packet); }
private void VersionOutdated(ClientIncomingPacket packet) { Logging.WriteLine("Version is outdated!!!! please update ASAP"); }
private void StartServer(ClientIncomingPacket packet) { this.AmountOfSlots = packet.ReadInt(); //Program.InitEnvironment(); }
private void ShutDownServerDialogged(ClientIncomingPacket packet) { this.keepThreadAlive = false; MessageBox.Show("Startup has failed due to the following reason\r\n\r\n" + packet.ReadString(), "Startup failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification, false); FirewindEnvironment.PreformShutDown(true); Environment.Exit(Environment.ExitCode); }
private void ShutDownServer(ClientIncomingPacket packet) { this.keepThreadAlive = false; FirewindEnvironment.PreformShutDown(true); Environment.Exit(Environment.ExitCode); }
private void SendServerVersion(ClientIncomingPacket packet) { connection.sendData(new ServerVersionResponse(1)); }
private void SendPingBack(ClientIncomingPacket packet) { connection.sendData(new PingRepsonse()); }
private void SendLicenseToServer(ClientIncomingPacket packet) { connection.sendData(new OutgoingSerialPacket(this.username, this.serial)); }
private void RunQuery(ClientIncomingPacket packet) { try { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery(packet.ReadString()); } connection.sendData(new QueryResult(true)); } catch { connection.sendData(new QueryResult(false)); } }
private void PingReceived(ClientIncomingPacket packet) { //connection.sendData(new PingRepsonse()); }