/// <summary> /// This function is fired when data is received from a stream /// </summary> /// <param name="stream">The stream that sended the data</param> /// <param name="message">The message the stream sended</param> protected override void ProcessData(string message) { //message= @"\search\sesskey\0\profileid\0\namespaceid\1\email\[email protected]\gamename\conflictsopc\final\"; message = RequstFormatConversion(message); if (message[0] != '\\') { GameSpyUtils.SendGPError(this, GPErrorCode.Parse, "An invalid request was sended."); return; } string[] commands = message.Split("\\final\\"); foreach (string command in commands) { if (command.Length < 1) { continue; } // Read client message, and parse it into key value pairs string[] recieved = command.TrimStart('\\').Split('\\'); Dictionary <string, string> dict = GameSpyUtils.ConvertGPResponseToKeyValue(recieved); CommandSwitcher.Switch(this, dict); } }
/// <summary> /// Main listner loop. Keeps an open stream between the client and server while /// the client is logged in / playing /// </summary> protected override void ProcessData(string message) { //message = @"\login\\challenge\l73Iv120dsOnQIA5hCBIqQSkojR191hy\user\retrospy@[email protected]\response\05d45e1b1bf6fbe6b6590785ec8dbe70\port\-9805\productid\10469\gamename\conflictsopc\namespaceid\1\id\1\final\"; message = RequstFormatConversion(message); if (message[0] != '\\') { GameSpyUtils.SendGPError(this, GPErrorCode.General, "An invalid request was sended."); return; } string[] commands = message.Split("\\final\\"); foreach (string command in commands) { if (command.Length < 1) { continue; } // Read client message, and parse it into key value pairs string[] recieved = command.TrimStart('\\').Split('\\'); Dictionary <string, string> dict = GameSpyUtils.ConvertGPResponseToKeyValue(recieved); CommandSwitcher.Switch(this, dict, OnSuccessfulLogin, OnStatusChanged); } }
protected override void OnReceived(string message) { message = RequstFormatConversion(message); if (message[0] != '\\') { GameSpyUtils.SendGPError(this, GPErrorCode.Parse, "An invalid request was sended."); return; } string[] commands = message.Split("\\final\\"); foreach (string command in commands) { if (command.Length < 1) { continue; } // Read client message, and parse it into key value pairs string[] recieved = command.TrimStart('\\').Split('\\'); Dictionary <string, string> dict = GameSpyUtils.ConvertGPResponseToKeyValue(recieved); CommandSwitcher.Switch(this, dict); } }
/// <summary> /// Called when a connection comes in on the CDKey server /// known messages /// \ka\ = keep alive from the game server every 20s, we don't care about this /// \auth\ ... = authenticate cd key, this is what we care about /// \disc\ ... = disconnect cd key, because there's checks if the cd key is in use, which we don't care about really, but we could if we wanted to /// </summary> protected override void OnReceived(EndPoint endPoint, byte[] message) { string decrypted = Enctypex.XorEncoding(message, 0); decrypted.Replace(@"\r\n", "").Replace("\0", ""); string[] recieved = decrypted.TrimStart('\\').Split('\\'); Dictionary <string, string> recv = GameSpyUtils.ConvertGPResponseToKeyValue(recieved); CommandSwitcher.Switch(this, endPoint, recv); }
protected override void OnReceived(string message) { if (message[0] != '\\') { return; } string[] recieved = message.TrimStart('\\').Split('\\'); Dictionary <string, string> dict = GameSpyUtils.ConvertGPResponseToKeyValue(recieved); CommandSwitcher.Switch(this, dict); }
/// <summary> /// This function is fired when data is received from a stream /// </summary> /// <param name="stream">The stream that sended the data</param> /// <param name="message">The message the stream sended</param> protected override void ProcessData(string message) { message = message.Replace(@"\final\", ""); string decodedmsg = GameSpyLib.Extensions.Enctypex.XorEncoding(message, 1); if (decodedmsg[0] != '\\') { return; } string[] recieved = decodedmsg.TrimStart('\\').Split('\\'); Dictionary <string, string> dict = GameSpyUtils.ConvertGPResponseToKeyValue(recieved); CommandSwitcher.Switch(this, dict); }
/// <summary> /// Called when a connection comes in on the CDKey server /// known messages /// \ka\ = keep alive from the game server every 20s, we don't care about this /// \auth\ ... = authenticate cd key, this is what we care about /// \disc\ ... = disconnect cd key, because there's checks if the cd key is in use, which we don't care about really, but we could if we wanted to /// </summary> protected override void ProcessAccept(UDPPacket packet) { // If we dont reply, we must manually release the EventArgs back to the pool Replied = false; try { // Decrypt message IPEndPoint remote = (IPEndPoint)packet.AsyncEventArgs.RemoteEndPoint; string decrypted = Enctypex.XorEncoding(packet.BytesRecieved, 0).Trim('\\'); string[] recieved = decrypted.TrimStart('\\').Split('\\'); Dictionary <string, string> recv = GameSpyUtils.ConvertGPResponseToKeyValue(recieved); switch (recieved[0]) { //keep client alive request, we skip this case "ka": case "auth": case "resp": case "skey": CDKeyHandler.IsCDKeyValid(this, packet, recv); break; case "disc": CDKeyHandler.DisconnectRequest(packet, recv); break; default: CDKeyHandler.InvalidCDKeyRequest(this, packet, recv); break; } } catch (Exception e) { LogWriter.Log.WriteException(e); } finally { // Release so that we can pool the EventArgs to be used on another connection if (!Replied) { Release(packet.AsyncEventArgs); } } }