/// <summary> /// Handles the packet. /// </summary> /// <param name='packet'> /// Packet. /// </param> /// <param name='client'> /// Client. /// </param> public void HandlePacket(SchumixPacket packet, TcpClient client) { var hst = client.Client.RemoteEndPoint.ToString().Split(SchumixBase.Colon)[0]; int packetid = 0; try { packetid = packet.Read <int>(); } catch (Exception) { var packet2 = new SchumixPacket(); packet2.Write <int>((int)Opcode.SCMSG_PACKET_NULL); packet2.Write <string>(sLConsole.GetString("Wrong packetid, aborting connection!")); ClientSocket.SendPacketToSCS(packet); Log.Warning("ClientPacketHandler", sLConsole.GetString("Wrong packetid, aborting connection!")); return; } Log.Debug("ClientPacketHandler", sLConsole.GetString("Got packet with ID: {0} from: {1}"), packetid, client.Client.RemoteEndPoint); if (PacketMethodMap.ContainsKey((Opcode)packetid)) { PacketMethodMap[(Opcode)packetid].Method.Invoke(packet, hst); return; } else { Log.Notice("ClientPacketHandler", sLConsole.GetString("Received unhandled packetid: {0}"), packetid); } }
/// <summary> /// Start listening. /// </summary> public void Socket() { Log.Notice("ClientSocket", sLConsole.GetString("Successfully started the ClientSocket.")); Log.Notice("ClientSocket", sLConsole.GetString("Client connection from: {0}"), client.Client.RemoteEndPoint); var client_thread = new Thread(new ParameterizedThreadStart(ClientHandler)); client_thread.Start(client); Thread.Sleep(50); var packet = new SchumixPacket(); packet.Write <int>((int)Opcode.CMSG_REQUEST_AUTH); packet.Write <string>(SchumixBase.GetGuid().ToString()); packet.Write <string>(sUtilities.Md5(_password)); packet.Write <string>(SchumixBase.ServerIdentify); SendPacketToSCS(packet); }