public static void SendBlockList(GPCMSession session) { if (session.PlayerInfo.BlockListSent) { return; } session.PlayerInfo.BlockListSent = true; string sendingBuffer = @"\blk\"; Dictionary <string, object> result = SendBlockListQuery.SearchBlockList(session.PlayerInfo.Profileid, session.PlayerInfo.NamespaceID); uint[] profileids; if (result != null) { profileids = result.Values.Cast <uint>().ToArray(); sendingBuffer += result.Count + @"\list\"; for (int i = 0; i < profileids.Length; i++) { //last one we do not add , if (i == profileids.Length - 1) { sendingBuffer += profileids[i]; break; } sendingBuffer += profileids[i] + @","; } sendingBuffer += @"\final\"; } else { sendingBuffer = @"\blk\0\list\\final\"; } session.SendAsync(sendingBuffer); }
/// <summary> /// Send a presence error /// </summary> /// <param name="session">The stream that will receive the error</param> /// <param name="errorCode">The error code</param> /// <param name="operationID">The operation id</param> public static void SendGPCMError(GPCMSession session, GPErrorCode errorCode, uint operationID) { string errorMsg = ErrorMsg.GetErrorMsg(errorCode); string sendingBuffer = string.Format(@"\error\\err\{0}\fatal\\errmsg\{1}\id\{2}\final\", (uint)errorCode, errorMsg, operationID); session.SendAsync(sendingBuffer); }
protected virtual void Response(GPCMSession session) { if (_sendingBuffer == null) { return; } session.SendAsync(_sendingBuffer); }
//********************************************************** //\bm\<MESSAGE>\f\<from profileid>\msg\<>\final\ //\bm\<UTM>\f\<from profileid>\msg\<>\final\ //\bm\<REQUEST>\f\<from profileid>\msg\|signed|\final\ //\bm\<AUTH>\f\<from profileid>\final\ //\bm\<REVOKE>\f\<from profileid>\final\ //\bm\<STATUS>\f\<from profileid>\msg\|s|<status code>|ss|<status string>|ls|<location string>|ip|<>|p|<port>|qm|<quiet mode falgs>\final\ //\bm\<INVITE>\f\<from profileid>\msg\|p|<productid>|l|<location string> //\bm\<ping>\f\<from profileid>\msg\final\ //\bm\<pong>\f\<from profileid>\final\ public static void SendBuddyList(GPCMSession session) { // \bdy\<number of friends>\list\<array of profileids>\ //total number of friends // we have to separate friends by productid,namespaceid,partnerid,gamename //because you will have different friends in different game if (session.PlayerInfo.BuddiesSent) { return; } session.PlayerInfo.BuddiesSent = true; //return; string sendingBuffer = @"\bdy\"; var result = SendBuddiesQuery.SearchBuddiesId(session.PlayerInfo.Profileid, session.PlayerInfo.NamespaceID); uint[] profileids; if (result != null) { //convert the object in dictionary to uint array profileids = result.Values.Cast <uint>().ToArray(); sendingBuffer += profileids.Length + @"\list\"; for (int i = 0; i < profileids.Length; i++) { //last one we do not add , if (i == profileids.Length - 1) { sendingBuffer += profileids[i]; break; } sendingBuffer += profileids[i] + @","; } sendingBuffer += @"\final\"; session.SendAsync(sendingBuffer); //we send the player's status info to client SendBuddyStatusInfo(session, profileids); } else { sendingBuffer = @"\bdy\0\list\\final\"; session.SendAsync(sendingBuffer); } }
public static void SendBuddyStatusInfo(GPCMSession session, uint[] profileids) { Dictionary <string, object> result; foreach (uint profileid in profileids) { string sendingBuffer = @"\bm\" + (uint)GPBasic.BmStatus + @"\f\"; result = SendBuddiesQuery.GetStatusInfo(profileid, session.PlayerInfo.NamespaceID); sendingBuffer += profileid + @"\msg\"; sendingBuffer += @"|s|" + Convert.ToUInt32(result["status"]); sendingBuffer += @"|ss|" + result["statstring"].ToString(); sendingBuffer += @"|ls|" + result["location"].ToString(); sendingBuffer += @"|ip|" + result["lastip"]; sendingBuffer += @"|p|" + Convert.ToUInt32(result["port"]); sendingBuffer += @"|qm|" + result["quietflags"] + @"\final\"; session.SendAsync(sendingBuffer); } }
/// <summary> /// Send others profile. /// </summary> public static void SendProfile(GPCMSession session, Dictionary <string, string> recv) { //TODO _recv = recv; // \getprofile\\sesskey\19150\profileid\2\id\2\final\ //profileid is IsContainAllKey(); if (_error != GPErrorCode.NoError) { GameSpyUtils.SendGPError(session, _error, "Parsing error."); return; } var result = GetProfileQuery.GetProfileInfo(Convert.ToUInt32(_recv["profileid"]), Convert.ToUInt32(_recv["sesskey"])); if (result == null) { GameSpyUtils.SendGPError(session, GPErrorCode.GetProfileBadProfile, "Unable to get profile information."); return; } string sendingBuffer = @"\pi\\profileid\" + _recv["profileid"]; if (result["nick"].ToString().Length > 0) { sendingBuffer += @"\nick\" + result["nick"].ToString(); } if (result["uniquenick"].ToString().Length > 0) { sendingBuffer += @"\uniquenick\" + result["uniquenick"].ToString(); } if (result["email"].ToString().Length > 0) { sendingBuffer += @"\email\" + result["email"].ToString(); } if (result["firstname"].ToString().Length > 0) { sendingBuffer += @"\firstname\" + result["firstname"].ToString(); } if (result["lastname"].ToString().Length > 0) { sendingBuffer += @"\firstname\" + result["lastname"].ToString(); } //if (result["icquin"].ToString().Length > 0) // sendingBuffer += @"\icquin\" + Convert.ToUInt32(result["icquin"]); //if (result["homepage"].ToString().Length > 0) // sendingBuffer += @"\homepage\" + result["homepage"].ToString(); //if (result["zipcode"].ToString().Length > 0) // sendingBuffer += @"\zipcode\" + result["zipcode"].ToString(); //if (result["countrycode"].ToString().Length > 0) // sendingBuffer += @"\countrycode\" + result["countrycode"].ToString(); //float longtitude; //if (result["longitude"].ToString().Length > 0) //{ // float.TryParse(result["longitude"].ToString(), out longtitude); // sendingBuffer += @"\lon\" + longtitude; //} //float latitude; //if (result["latitude"].ToString().Length > 0) //{ // float.TryParse(result["latitude"].ToString(), out latitude); // sendingBuffer += @"\lat\" + latitude; //} //if (result["location"].ToString().Length > 0) // sendingBuffer += @"\loc\" + result["location"].ToString(); //if (result["birthday"].ToString().Length > 0 && result["birthmonth"].ToString().Length > 0 && result["birthyear"].ToString().Length > 0) //{ // uint birthday = (Convert.ToUInt32(result["birthday"]) << 24) | (Convert.ToUInt32(result["birthmonth"]) << 16) | Convert.ToUInt32(result["birthyear"]); // sendingBuffer += @"\birthday\" + birthday; //} //PlayerSexType playerSexType; //if (!Enum.TryParse(result["sex"].ToString().ToUpper(), out playerSexType)) // if (playerSexType == PlayerSexType.PAT) // sendingBuffer += @"\sex\2"; //if (playerSexType == PlayerSexType.FEMALE) // sendingBuffer += @"\sex\1"; //if (playerSexType == PlayerSexType.MALE) // sendingBuffer += @"\sex\0"; //PublicMasks mask; //if (result["publicmask"].ToString().Length > 0) // if (!Enum.TryParse(result["publicmask"].ToString(), out mask)) // sendingBuffer += @"\publicmask\" + mask; //if (result["aim"].ToString().Length > 0) // sendingBuffer += @"\aim\" + result["aim"].ToString(); //if (result["picture"].ToString().Length > 0) // sendingBuffer += @"\picture\" + Convert.ToUInt16(result["picture"]); //if (result["occupationid"].ToString().Length > 0) // sendingBuffer += @"\occ\" + Convert.ToUInt16(result["occupationid"]); //if (result["industryid"].ToString().Length > 0) // sendingBuffer += @"\ind\" + Convert.ToUInt16(result["industryid"]); //if (result["incomeid"].ToString().Length > 0) // sendingBuffer += @"\inc\" + Convert.ToUInt16(result["incomeid"]); //if (result["marriedid"].ToString().Length > 0) // sendingBuffer += @"\mar\" + Convert.ToUInt16(result["marriedid"]); //if (result["childcount"].ToString().Length > 0) // sendingBuffer += @"\chc\" + Convert.ToUInt16(result["childcount"]); //if (result["interests1"].ToString().Length > 0) // sendingBuffer += @"\i1\" + result["interests1"].ToString(); //if (result["ownership1"].ToString().Length > 0) // sendingBuffer += @"\o1\" + result["ownership1"].ToString(); //if (result["connectiontype"].ToString().Length > 0) // sendingBuffer += @"\conn\" + Convert.ToUInt16(result["connectiontype"]); // SUPER NOTE: Please check the Signature of the PID, otherwise when it will be compared with other peers, it will break everything (See gpiPeer.c @ peerSig) string signature = GameSpyLib.Common.GameSpyRandom.GenerateRandomString(10, GameSpyLib.Common.GameSpyRandom.StringType.Hex); sendingBuffer += @"\sig\" + signature + @"\id\" + recv["id"] + @"\final\"; session.SendAsync(sendingBuffer); session.PlayerInfo.BuddiesSent = true; }