private void DumpSessionInfo(Matching.Session session) { Matching.SessionInfo sessionInfo = session.sessionInfo; Matching.SessionAttributeInfo[] sessionAttributes = session.sessionAttributes; Matching.SessionMemberInfo[] members = session.members; OnScreenLog.Add("session: " + sessionInfo.sessionName + ", " + sessionInfo.numMembers + ", " + sessionInfo.maxMembers + ", " + sessionInfo.openSlots + ", " + sessionInfo.reservedSlots + ", " + sessionInfo.worldId + ", " + sessionInfo.roomId); for (int i = 0; i < sessionAttributes.Length; i++) { string text = " Attribute " + i + ": " + sessionAttributes[i].attributeName; switch (sessionAttributes[i].attributeValueType) { case Matching.EnumAttributeValueType.SESSION_ATTRIBUTE_VALUE_INT: text = text + " = " + sessionAttributes[i].attributeIntValue; break; case Matching.EnumAttributeValueType.SESSION_ATTRIBUTE_VALUE_BINARY: text = text + " = " + sessionAttributes[i].attributeBinValue; break; default: text += ", has bad value type"; break; } text = text + ", " + sessionAttributes[i].attributeType; OnScreenLog.Add(text); } if (members == null) { return; } for (int j = 0; j < members.Length; j++) { OnScreenLog.Add(" Member " + j + ": " + members[j].npOnlineID + ", Type: " + members[j].memberFlag); if (members[j].addr != 0) { OnScreenLog.Add(" IP: " + IntIPToIPString(members[j].addr) + " port " + members[j].port + " 0x" + members[j].port.ToString("X")); } else { OnScreenLog.Add(" IP: unknown "); } sessionAttributes = session.memberAttributes[j]; if (sessionAttributes.Length == 0) { OnScreenLog.Add(" No Member Attributes"); } for (int k = 0; k < sessionAttributes.Length; k++) { string text2 = " Attribute " + k + ": " + sessionAttributes[k].attributeName; switch (sessionAttributes[k].attributeValueType) { case Matching.EnumAttributeValueType.SESSION_ATTRIBUTE_VALUE_INT: text2 = text2 + " = " + sessionAttributes[k].attributeIntValue; break; case Matching.EnumAttributeValueType.SESSION_ATTRIBUTE_VALUE_BINARY: text2 = text2 + " = " + sessionAttributes[k].attributeBinValue; break; default: text2 += ", has bad value type"; break; } OnScreenLog.Add(text2); } } }
private void OnMatchingJoinedSession(Messages.PluginMessage msg) { OnScreenLog.Add("Joined PSN matching session... waiting on session info in OnMatchingUpdatedSession()"); }
public void MenuSetupSession(MenuStack menuStack) { bool isSignedInPSN = User.IsSignedInPSN; bool inSession = Matching.InSession; bool sessionIsBusy = Matching.SessionIsBusy; menuSession.Update(); if (menuSession.AddItem("Create & Join Session", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Creating session..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.name = "APP_VERSION"; sessionAttribute.intValue = appVersion; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.name = "PASSWORD"; sessionAttribute.binValue = "NO"; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.name = "CAR_TYPE"; sessionAttribute.binValue = "CATMOB"; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.name = "LEVEL"; sessionAttribute.intValue = 1; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.name = "RACE_TRACK"; sessionAttribute.binValue = "TURKEY"; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.name = "GAME_DETAILS"; sessionAttribute.intValue = gameDetails; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.name = "TEST_BIN_SEARCH"; sessionAttribute.binValue = "BIN_VALUE"; Matching.AddSessionAttribute(sessionAttribute); string name = "Test Session"; int serverID = 0; int worldID = 0; int numSlots = 8; string empty = string.Empty; string ps4SessionStatus = "Toolkit Sample Session"; ErrorHandler(Matching.CreateSession(name, serverID, worldID, numSlots, empty, SignallingType, Matching.EnumSessionType.SESSION_TYPE_PUBLIC, ps4SessionStatus)); } if (menuSession.AddItem("Create & Join Private Session", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Creating private session... password is required"); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.name = "APP_VERSION"; sessionAttribute2.intValue = appVersion; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.name = "PASSWORD"; sessionAttribute2.binValue = "YES"; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.name = "CAR_TYPE"; sessionAttribute2.binValue = "CATMOB"; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.name = "LEVEL"; sessionAttribute2.intValue = 1; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.name = "RACE_TRACK"; sessionAttribute2.binValue = "TURKEY"; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.name = "GAME_DETAILS"; sessionAttribute2.intValue = gameDetails; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.name = "TEST_BIN_SEARCH"; sessionAttribute2.binValue = "BIN_VALUE"; Matching.AddSessionAttribute(sessionAttribute2); string name2 = "Test Session"; int serverID2 = 0; int worldID2 = 0; int numSlots2 = 8; string password = sessionPassword; string ps4SessionStatus2 = "Toolkit Sample Session"; ErrorHandler(Matching.CreateSession(name2, serverID2, worldID2, numSlots2, password, SignallingType | Matching.FlagSessionCreate.CREATE_PASSWORD_SESSION, Matching.EnumSessionType.SESSION_TYPE_PRIVATE, ps4SessionStatus2)); } if (menuSession.AddItem("Create & Join Friend Session", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Creating Friend session..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.name = "APP_VERSION"; sessionAttribute3.intValue = appVersion; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.name = "PASSWORD"; sessionAttribute3.binValue = "YES"; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.name = "CAR_TYPE"; sessionAttribute3.binValue = "CATMOB"; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.name = "LEVEL"; sessionAttribute3.intValue = 1; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.name = "RACE_TRACK"; sessionAttribute3.binValue = "TURKEY"; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.name = "GAME_DETAILS"; sessionAttribute3.intValue = gameDetails; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.name = "TEST_BIN_SEARCH"; sessionAttribute3.binValue = "BIN_VALUE"; Matching.AddSessionAttribute(sessionAttribute3); string name3 = "Test Session"; int serverID3 = 0; int worldID3 = 0; int numSlots3 = 8; int friendSlots = 8; string password2 = sessionPassword; string ps4SessionStatus3 = "Toolkit Sample Session"; ErrorHandler(Matching.CreateFriendsSession(name3, serverID3, worldID3, numSlots3, friendSlots, password2, SignallingType | Matching.FlagSessionCreate.CREATE_PASSWORD_SESSION, ps4SessionStatus3)); } if (menuSession.AddItem("Find Sessions", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding sessions..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute4 = new Matching.SessionAttribute(); sessionAttribute4.name = "APP_VERSION"; sessionAttribute4.intValue = appVersion; sessionAttribute4.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ; Matching.AddSessionAttribute(sessionAttribute4); int serverID4 = 0; int worldID4 = 0; ErrorHandler(Matching.FindSession(serverID4, worldID4)); } if (menuSession.AddItem("Find Sessions (bin search)", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding sessions..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute5 = new Matching.SessionAttribute(); sessionAttribute5.name = "TEST_BIN_SEARCH"; sessionAttribute5.binValue = "BIN_VALUE"; sessionAttribute5.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ; Matching.AddSessionAttribute(sessionAttribute5); int serverID5 = 0; int worldID5 = 0; ErrorHandler(Matching.FindSession(serverID5, worldID5, Matching.FlagSessionSearch.SEARCH_REGIONAL_SESSIONS)); } if (menuSession.AddItem("Find Friend Sessions", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding friend sessions..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute6 = new Matching.SessionAttribute(); sessionAttribute6.name = "APP_VERSION"; sessionAttribute6.intValue = appVersion; sessionAttribute6.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ; Matching.AddSessionAttribute(sessionAttribute6); int serverID6 = 0; int worldID6 = 0; ErrorHandler(Matching.FindSession(serverID6, worldID6, Matching.FlagSessionSearch.SEARCH_FRIENDS_SESSIONS)); } if (menuSession.AddItem("Find Regional Sessions", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding friend sessions..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute7 = new Matching.SessionAttribute(); sessionAttribute7.name = "APP_VERSION"; sessionAttribute7.intValue = appVersion; sessionAttribute7.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ; Matching.AddSessionAttribute(sessionAttribute7); int serverID7 = 0; int worldID7 = 0; ErrorHandler(Matching.FindSession(serverID7, worldID7, Matching.FlagSessionSearch.SEARCH_REGIONAL_SESSIONS)); } if (menuSession.AddItem("Find Random Sessions", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding sessions in a random order..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute8 = new Matching.SessionAttribute(); sessionAttribute8.name = "APP_VERSION"; sessionAttribute8.intValue = appVersion; sessionAttribute8.searchOperator = Matching.EnumSearchOperators.MATCHING_OPERATOR_EQ; Matching.AddSessionAttribute(sessionAttribute8); int serverID8 = 0; int worldID8 = 0; ErrorHandler(Matching.FindSession(serverID8, worldID8, Matching.FlagSessionSearch.SEARCH_RANDOM_SESSIONS)); } bool flag = availableSessions != null && availableSessions.Length > 0; if (menuSession.AddItem("Join 1st Found Session", isSignedInPSN && flag && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Joining PSN session: " + availableSessions[0].sessionInfo.sessionName); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute9 = new Matching.SessionAttribute(); sessionAttribute9.name = "CAR_TYPE"; sessionAttribute9.binValue = "CATMOB"; Matching.AddSessionAttribute(sessionAttribute9); ErrorHandler(Matching.JoinSession(availableSessions[0].sessionInfo.sessionID, sessionPassword)); } if (menuSession.AddBackIndex("Back")) { menuStack.PopMenu(); } }
public void MenuInSession(MenuStack menuStack) { bool isSignedInPSN = User.IsSignedInPSN; bool inSession = Matching.InSession; bool sessionIsBusy = Matching.SessionIsBusy; bool isHost = Matching.IsHost; MenuLayout menuLayout = (!isHost) ? menuInSessionClient : menuInSessionHosting; menuLayout.Update(); if (isHost && menuLayout.AddItem("Modify Session", isSignedInPSN && inSession && !sessionIsBusy)) { OnScreenLog.Add("Modifying session..."); Matching.ClearModifySessionAttributes(); gameDetails += 100; Matching.ModifySessionAttribute modifySessionAttribute = new Matching.ModifySessionAttribute(); modifySessionAttribute.name = "GAME_DETAILS"; modifySessionAttribute.intValue = gameDetails; Matching.AddModifySessionAttribute(modifySessionAttribute); ErrorHandler(Matching.ModifySession(Matching.EnumAttributeType.SESSION_INTERNAL_ATTRIBUTE)); } if (menuLayout.AddItem("Modify Member Attribute", isSignedInPSN && inSession && !sessionIsBusy)) { OnScreenLog.Add("Modifying Member Attribute..."); Matching.ClearModifySessionAttributes(); Matching.ModifySessionAttribute modifySessionAttribute2 = new Matching.ModifySessionAttribute(); modifySessionAttribute2.name = "CAR_TYPE"; cartype++; if (cartype > 3) { cartype = 0; } switch (cartype) { case 0: modifySessionAttribute2.binValue = "CATMOB"; break; case 1: modifySessionAttribute2.binValue = "CARTYPE1"; break; case 2: modifySessionAttribute2.binValue = "CARTYPE2"; break; case 3: modifySessionAttribute2.binValue = "CARTYPE3"; break; } modifySessionAttribute2.intValue = gameDetails; Matching.AddModifySessionAttribute(modifySessionAttribute2); ErrorHandler(Matching.ModifySession(Matching.EnumAttributeType.SESSION_MEMBER_ATTRIBUTE)); } if (!sendingData) { if (menuLayout.AddItem("Start Sending Data", isSignedInPSN && inSession && !sessionIsBusy)) { sendingData = true; } } else if (menuLayout.AddItem("Stop Sending Data", isSignedInPSN && inSession && !sessionIsBusy)) { sendingData = false; } if (menuLayout.AddItem("Leave Session", isSignedInPSN && inSession && !sessionIsBusy)) { OnScreenLog.Add("Leaving session..."); ErrorHandler(Matching.LeaveSession()); } if (menuLayout.AddItem("List session members", isSignedInPSN && inSession && !sessionIsBusy)) { Matching.Session session = Matching.GetSession(); Matching.SessionMemberInfo[] members = session.members; for (int i = 0; i < members.Length; i++) { Matching.SessionMemberInfo sessionMemberInfo = members[i]; string msg = i + "/memberId:" + sessionMemberInfo.memberId + "/memberFlag:" + sessionMemberInfo.memberFlag + "/addr:" + sessionMemberInfo.addr + "/natType:" + sessionMemberInfo.natType + "/port:" + sessionMemberInfo.port; OnScreenLog.Add(msg); } } if (menuLayout.AddItem("Invite Friend", isSignedInPSN && inSession && !sessionIsBusy)) { OnScreenLog.Add("Invite Friend..."); ErrorHandler(Matching.InviteToSession("Invite Test", 8)); } if (menuLayout.AddBackIndex("Back")) { menuStack.PopMenu(); } if (Matching.IsHost) { NetworkPlayer[] connections = Network.connections; GUI.Label(new Rect(Screen.width - 200, Screen.height - 200, 200f, 64f), connections.Length.ToString()); } }
private void OnCommerceDialogClosed(Messages.PluginMessage msg) { Dialogs.NpDialogReturn dialogResult = Dialogs.GetDialogResult(); OnScreenLog.Add("Commerce dialog closed with result: " + dialogResult.result + " PlusAllowed:" + dialogResult.plusAllowed); }
private void HasAutoloadDataFinishDelegate(DataSerializerErrorCode errNo, Boolean hasAutoloadData) { OnScreenLog.Add((!hasAutoloadData) ? "No, you haven't" : "Yes, you have"); }
private void OnMessageError(Messages.PluginMessage msg) { OnScreenLog.Add(" OnMessageError error code: " + Messaging.GetErrorFromMessage(msg).ToString("X")); }
private void OnSomeEvent(Messages.PluginMessage msg) { OnScreenLog.Add("Event: " + msg.type); }
private void OnProfileDialogClosed(Messages.PluginMessage msg) { OnScreenLog.Add("Profile dialog closed with result: " + Dialogs.GetDialogResult().result); }
public void MenuMessaging(MenuStack menuStack) { this.menuMessaging.Update(); if (this.menuMessaging.AddItem("Show Messages & Invites", User.get_IsSignedInPSN() && !Messaging.IsBusy())) { Messaging.ShowRecievedDataMessageDialog(); } if (this.menuMessaging.AddItem("Send Session Invite", User.get_IsSignedInPSN() && Matching.get_InSession())) { string text = "Join my session"; int num = 8; Matching.InviteToSession(text, num); } if (this.menuMessaging.AddItem("Send Game Invite", User.get_IsSignedInPSN() && !Messaging.IsBusy())) { byte[] data = new SonyNpMessaging.GameInviteData { taunt = "I got an awesome score, can you do better?", level = 1, score = 123456789 }.WriteToBuffer(); Messaging.MsgRequest msgRequest = new Messaging.MsgRequest(); msgRequest.set_body("Game invite"); msgRequest.expireMinutes = 30; msgRequest.set_data(data); msgRequest.npIDCount = 8; string dataDescription = "Some data to test invite messages"; string dataName = "Test data"; msgRequest.dataDescription = dataDescription; msgRequest.dataName = dataName; msgRequest.iconPath = Application.get_streamingAssetsPath() + "/PSP2SessionImage.jpg"; Messaging.SendMessage(msgRequest); } if (this.menuMessaging.AddItem("Send Data Message", User.get_IsSignedInPSN() && !Messaging.IsBusy())) { SonyNpMessaging.GameData gameData = default(SonyNpMessaging.GameData); gameData.text = "Here's some data"; gameData.item1 = 2; gameData.item2 = 987654321; byte[] data2 = gameData.WriteToBuffer(); Messaging.MsgRequest msgRequest2 = new Messaging.MsgRequest(); msgRequest2.set_body("Data message"); msgRequest2.expireMinutes = 0; msgRequest2.set_data(data2); msgRequest2.npIDCount = 8; string dataDescription2 = "Some data to test messages"; string dataName2 = "Test data"; msgRequest2.dataDescription = dataDescription2; msgRequest2.dataName = dataName2; msgRequest2.iconPath = Application.get_streamingAssetsPath() + "/PSP2SessionImage.jpg"; Messaging.SendMessage(msgRequest2); } if (this.menuMessaging.AddItem("Send In Game Data (Session)", Matching.get_InSession() && !Messaging.IsBusy())) { Matching.SessionMemberInfo[] members = Matching.GetSession().members; if (members == null) { return; } int num2 = -1; for (int i = 0; i < members.Length; i++) { if ((members[i].memberFlag & 4) == null) { num2 = i; break; } } if (num2 >= 0) { OnScreenLog.Add("Sending in game data message to " + members[num2].get_npOnlineID()); SonyNpMessaging.GameData gameData2 = default(SonyNpMessaging.GameData); gameData2.text = "Here's some data"; gameData2.item1 = 2; gameData2.item2 = 987654321; byte[] array = gameData2.WriteToBuffer(); Messaging.SendInGameDataMessage(members[num2].get_npID(), array); } else { OnScreenLog.Add("No session member to send to."); } } if (this.menuMessaging.AddItem("Send In Game Message (Friend)", User.get_IsSignedInPSN() && !Messaging.IsBusy())) { Friends.Friend[] cachedFriendsList = Friends.GetCachedFriendsList(); if (cachedFriendsList.Length > 0) { int num3 = 0; if (num3 >= 0) { OnScreenLog.Add("Sending in game data message to " + cachedFriendsList[num3].get_npOnlineID()); SonyNpMessaging.GameData gameData3 = default(SonyNpMessaging.GameData); gameData3.text = "Here's some data"; gameData3.item1 = 2; gameData3.item2 = 987654321; byte[] array2 = gameData3.WriteToBuffer(); Messaging.SendInGameDataMessage(cachedFriendsList[num3].get_npID(), array2); } else { OnScreenLog.Add("No friends in this context."); } } else { OnScreenLog.Add("No friends cached."); OnScreenLog.Add("refresh the friends list then try again."); } } if (this.menuMessaging.AddBackIndex("Back", true)) { menuStack.PopMenu(); } }
private void DumpSessionInfo(Matching.Session session) { Matching.SessionInfo sessionInfo = session.sessionInfo; Matching.SessionAttributeInfo[] array = session.sessionAttributes; Matching.SessionMemberInfo[] members = session.members; OnScreenLog.Add(string.Concat(new object[] { "session: ", sessionInfo.get_sessionName(), ", ", sessionInfo.numMembers, ", ", sessionInfo.maxMembers, ", ", sessionInfo.openSlots, ", ", sessionInfo.reservedSlots, ", ", sessionInfo.worldId, ", ", sessionInfo.roomId })); int i = 0; while (i < array.Length) { string text = string.Concat(new object[] { " Attribute ", i, ": ", array[i].get_attributeName() }); switch (array[i].attributeValueType) { case 2: text = text + " = " + array[i].attributeIntValue; break; case 3: goto IL_171; case 4: text = text + " = " + array[i].get_attributeBinValue(); break; default: goto IL_171; } IL_184: text = text + ", " + array[i].attributeType; OnScreenLog.Add(text); i++; continue; IL_171: text += ", has bad value type"; goto IL_184; } if (members == null) { return; } for (int j = 0; j < members.Length; j++) { OnScreenLog.Add(string.Concat(new object[] { " Member ", j, ": ", members[j].get_npOnlineID(), ", Type: ", members[j].memberFlag })); if (members[j].addr != 0) { OnScreenLog.Add(string.Concat(new object[] { " IP: ", this.IntIPToIPString(members[j].addr), " port ", members[j].port, " 0x", members[j].port.ToString("X") })); } else { OnScreenLog.Add(" IP: unknown "); } array = session.memberAttributes.get_Item(j); if (array.Length == 0) { OnScreenLog.Add(" No Member Attributes"); } int k = 0; while (k < array.Length) { string text2 = string.Concat(new object[] { " Attribute ", k, ": ", array[k].get_attributeName() }); switch (array[k].attributeValueType) { case 2: text2 = text2 + " = " + array[k].attributeIntValue; break; case 3: goto IL_379; case 4: text2 = text2 + " = " + array[k].get_attributeBinValue(); break; default: goto IL_379; } IL_38C: OnScreenLog.Add(text2); k++; continue; IL_379: text2 += ", has bad value type"; goto IL_38C; } } }
public void MenuInSession(MenuStack menuStack) { bool isSignedInPSN = User.get_IsSignedInPSN(); bool inSession = Matching.get_InSession(); bool sessionIsBusy = Matching.get_SessionIsBusy(); bool isHost = Matching.get_IsHost(); MenuLayout menuLayout = (!isHost) ? this.menuInSessionClient : this.menuInSessionHosting; menuLayout.Update(); if (isHost && menuLayout.AddItem("Modify Session", isSignedInPSN && inSession && !sessionIsBusy)) { OnScreenLog.Add("Modifying session..."); Matching.ClearModifySessionAttributes(); this.gameDetails += 100; Matching.ModifySessionAttribute modifySessionAttribute = new Matching.ModifySessionAttribute(); modifySessionAttribute.set_name("GAME_DETAILS"); modifySessionAttribute.intValue = this.gameDetails; Matching.AddModifySessionAttribute(modifySessionAttribute); this.ErrorHandler(Matching.ModifySession(8)); } if (menuLayout.AddItem("Modify Member Attribute", isSignedInPSN && inSession && !sessionIsBusy)) { OnScreenLog.Add("Modifying Member Attribute..."); Matching.ClearModifySessionAttributes(); Matching.ModifySessionAttribute modifySessionAttribute2 = new Matching.ModifySessionAttribute(); modifySessionAttribute2.set_name("CAR_TYPE"); this.cartype++; if (this.cartype > 3) { this.cartype = 0; } switch (this.cartype) { case 0: modifySessionAttribute2.set_binValue("CATMOB"); break; case 1: modifySessionAttribute2.set_binValue("CARTYPE1"); break; case 2: modifySessionAttribute2.set_binValue("CARTYPE2"); break; case 3: modifySessionAttribute2.set_binValue("CARTYPE3"); break; } modifySessionAttribute2.intValue = this.gameDetails; Matching.AddModifySessionAttribute(modifySessionAttribute2); this.ErrorHandler(Matching.ModifySession(16)); } if (!this.sendingData) { if (menuLayout.AddItem("Start Sending Data", isSignedInPSN && inSession && !sessionIsBusy)) { this.sendingData = true; } } else if (menuLayout.AddItem("Stop Sending Data", isSignedInPSN && inSession && !sessionIsBusy)) { this.sendingData = false; } if (menuLayout.AddItem("Leave Session", isSignedInPSN && inSession && !sessionIsBusy)) { OnScreenLog.Add("Leaving session..."); this.ErrorHandler(Matching.LeaveSession()); } if (menuLayout.AddItem("List session members", isSignedInPSN && inSession && !sessionIsBusy)) { Matching.SessionMemberInfo[] members = Matching.GetSession().members; for (int i = 0; i < members.Length; i++) { Matching.SessionMemberInfo sessionMemberInfo = members[i]; string msg = string.Concat(new object[] { i, "/memberId:", sessionMemberInfo.memberId, "/memberFlag:", sessionMemberInfo.memberFlag, "/addr:", sessionMemberInfo.addr, "/natType:", sessionMemberInfo.natType, "/port:", sessionMemberInfo.port }); OnScreenLog.Add(msg); } } if (menuLayout.AddItem("Invite Friend", isSignedInPSN && inSession && !sessionIsBusy)) { OnScreenLog.Add("Invite Friend..."); this.ErrorHandler(Matching.InviteToSession("Invite Test", 8)); } if (menuLayout.AddBackIndex("Back", true)) { menuStack.PopMenu(); } if (Matching.get_IsHost()) { NetworkPlayer[] connections = Network.get_connections(); GUI.Label(new Rect((float)(Screen.get_width() - 200), (float)(Screen.get_height() - 200), 200f, 64f), connections.Length.ToString()); } }
public void MenuSetupSession(MenuStack menuStack) { bool isSignedInPSN = User.get_IsSignedInPSN(); bool inSession = Matching.get_InSession(); bool sessionIsBusy = Matching.get_SessionIsBusy(); this.menuSession.Update(); if (this.menuSession.AddItem("Create & Join Session", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Creating session..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.set_name("APP_VERSION"); sessionAttribute.intValue = this.appVersion; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.set_name("PASSWORD"); sessionAttribute.set_binValue("NO"); Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.set_name("CAR_TYPE"); sessionAttribute.set_binValue("CATMOB"); Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.set_name("LEVEL"); sessionAttribute.intValue = 1; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.set_name("RACE_TRACK"); sessionAttribute.set_binValue("TURKEY"); Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.set_name("GAME_DETAILS"); sessionAttribute.intValue = this.gameDetails; Matching.AddSessionAttribute(sessionAttribute); sessionAttribute = new Matching.SessionAttribute(); sessionAttribute.set_name("TEST_BIN_SEARCH"); sessionAttribute.set_binValue("BIN_VALUE"); Matching.AddSessionAttribute(sessionAttribute); string text = "Test Session"; int num = 0; int num2 = 0; int num3 = 8; string empty = string.Empty; string text2 = "Toolkit Sample Session"; this.ErrorHandler(Matching.CreateSession(text, num, num2, num3, empty, this.SignallingType, 4, text2)); } if (this.menuSession.AddItem("Create & Join Private Session", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Creating private session... password is required"); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.set_name("APP_VERSION"); sessionAttribute2.intValue = this.appVersion; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.set_name("PASSWORD"); sessionAttribute2.set_binValue("YES"); Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.set_name("CAR_TYPE"); sessionAttribute2.set_binValue("CATMOB"); Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.set_name("LEVEL"); sessionAttribute2.intValue = 1; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.set_name("RACE_TRACK"); sessionAttribute2.set_binValue("TURKEY"); Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.set_name("GAME_DETAILS"); sessionAttribute2.intValue = this.gameDetails; Matching.AddSessionAttribute(sessionAttribute2); sessionAttribute2 = new Matching.SessionAttribute(); sessionAttribute2.set_name("TEST_BIN_SEARCH"); sessionAttribute2.set_binValue("BIN_VALUE"); Matching.AddSessionAttribute(sessionAttribute2); string text3 = "Test Session"; int num4 = 0; int num5 = 0; int num6 = 8; string text4 = this.sessionPassword; string text5 = "Toolkit Sample Session"; this.ErrorHandler(Matching.CreateSession(text3, num4, num5, num6, text4, this.SignallingType | 16, 8, text5)); } if (this.menuSession.AddItem("Create & Join Friend Session", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Creating Friend session..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.set_name("APP_VERSION"); sessionAttribute3.intValue = this.appVersion; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.set_name("PASSWORD"); sessionAttribute3.set_binValue("YES"); Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.set_name("CAR_TYPE"); sessionAttribute3.set_binValue("CATMOB"); Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.set_name("LEVEL"); sessionAttribute3.intValue = 1; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.set_name("RACE_TRACK"); sessionAttribute3.set_binValue("TURKEY"); Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.set_name("GAME_DETAILS"); sessionAttribute3.intValue = this.gameDetails; Matching.AddSessionAttribute(sessionAttribute3); sessionAttribute3 = new Matching.SessionAttribute(); sessionAttribute3.set_name("TEST_BIN_SEARCH"); sessionAttribute3.set_binValue("BIN_VALUE"); Matching.AddSessionAttribute(sessionAttribute3); string text6 = "Test Session"; int num7 = 0; int num8 = 0; int num9 = 8; int num10 = 8; string text7 = this.sessionPassword; string text8 = "Toolkit Sample Session"; this.ErrorHandler(Matching.CreateFriendsSession(text6, num7, num8, num9, num10, text7, this.SignallingType | 16, text8)); } if (this.menuSession.AddItem("Find Sessions", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding sessions..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute4 = new Matching.SessionAttribute(); sessionAttribute4.set_name("APP_VERSION"); sessionAttribute4.intValue = this.appVersion; sessionAttribute4.searchOperator = 1; Matching.AddSessionAttribute(sessionAttribute4); int num11 = 0; int num12 = 0; this.ErrorHandler(Matching.FindSession(num11, num12)); } if (this.menuSession.AddItem("Find Sessions (bin search)", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding sessions..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute5 = new Matching.SessionAttribute(); sessionAttribute5.set_name("TEST_BIN_SEARCH"); sessionAttribute5.set_binValue("BIN_VALUE"); sessionAttribute5.searchOperator = 1; Matching.AddSessionAttribute(sessionAttribute5); int num13 = 0; int num14 = 0; this.ErrorHandler(Matching.FindSession(num13, num14, 4096)); } if (this.menuSession.AddItem("Find Friend Sessions", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding friend sessions..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute6 = new Matching.SessionAttribute(); sessionAttribute6.set_name("APP_VERSION"); sessionAttribute6.intValue = this.appVersion; sessionAttribute6.searchOperator = 1; Matching.AddSessionAttribute(sessionAttribute6); int num15 = 0; int num16 = 0; this.ErrorHandler(Matching.FindSession(num15, num16, 1024)); } if (this.menuSession.AddItem("Find Regional Sessions", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding friend sessions..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute7 = new Matching.SessionAttribute(); sessionAttribute7.set_name("APP_VERSION"); sessionAttribute7.intValue = this.appVersion; sessionAttribute7.searchOperator = 1; Matching.AddSessionAttribute(sessionAttribute7); int num17 = 0; int num18 = 0; this.ErrorHandler(Matching.FindSession(num17, num18, 4096)); } if (this.menuSession.AddItem("Find Random Sessions", isSignedInPSN && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Finding sessions in a random order..."); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute8 = new Matching.SessionAttribute(); sessionAttribute8.set_name("APP_VERSION"); sessionAttribute8.intValue = this.appVersion; sessionAttribute8.searchOperator = 1; Matching.AddSessionAttribute(sessionAttribute8); int num19 = 0; int num20 = 0; this.ErrorHandler(Matching.FindSession(num19, num20, 262144)); } bool flag = this.availableSessions != null && this.availableSessions.Length > 0; if (this.menuSession.AddItem("Join 1st Found Session", isSignedInPSN && flag && !inSession && !sessionIsBusy)) { OnScreenLog.Add("Joining PSN session: " + this.availableSessions[0].sessionInfo.get_sessionName()); Matching.ClearSessionAttributes(); Matching.SessionAttribute sessionAttribute9 = new Matching.SessionAttribute(); sessionAttribute9.set_name("CAR_TYPE"); sessionAttribute9.set_binValue("CATMOB"); Matching.AddSessionAttribute(sessionAttribute9); this.ErrorHandler(Matching.JoinSession(this.availableSessions[0].sessionInfo.sessionID, this.sessionPassword)); } if (this.menuSession.AddBackIndex("Back", true)) { menuStack.PopMenu(); } }
private void OnMatchingJoinInvalidSession(Messages.PluginMessage msg) { OnScreenLog.Add("Failed to join session..."); OnScreenLog.Add(" Session search results may be stale."); }
private void OnSetTusVariables(Messages.PluginMessage msg) { OnScreenLog.Add("Sent TUS variables"); }
public void MenuUser(MenuStack menuStack) { bool isSignedInPSN = User.get_IsSignedInPSN(); this.menuUser.Update(); if (this.menuUser.AddItem("Get My Profile", !User.get_IsUserProfileBusy())) { ErrorCode errorCode = User.RequestUserProfile(); if (errorCode != null) { ResultCode resultCode = default(ResultCode); User.GetLastUserProfileError(ref resultCode); OnScreenLog.Add(string.Concat(new object[] { resultCode.get_className(), ": ", resultCode.lastError, ", sce error 0x", resultCode.lastErrorSCE.ToString("X8") })); } } if (this.menuUser.AddItem("Get Remote Profile (onlineID)", isSignedInPSN && !User.get_IsUserProfileBusy())) { ErrorCode errorCode2 = User.RequestRemoteUserProfileForOnlineID(this.remoteOnlineID); if (errorCode2 != null) { ResultCode resultCode2 = default(ResultCode); User.GetLastUserProfileError(ref resultCode2); OnScreenLog.Add(string.Concat(new object[] { resultCode2.get_className(), ": ", resultCode2.lastError, ", sce error 0x", resultCode2.lastErrorSCE.ToString("X8") })); } } if (this.menuUser.AddItem("Get Remote NpID", isSignedInPSN && !User.get_IsUserProfileBusy())) { ErrorCode errorCode3 = User.RequestRemoteUserNpID(this.remoteOnlineID); if (errorCode3 != null) { ResultCode resultCode3 = default(ResultCode); User.GetLastUserProfileError(ref resultCode3); OnScreenLog.Add(string.Concat(new object[] { resultCode3.get_className(), ": ", resultCode3.lastError, ", sce error 0x", resultCode3.lastErrorSCE.ToString("X8") })); } } if (this.menuUser.AddItem("Get Remote Profile (npID)", this.remoteNpID != null && isSignedInPSN && !User.get_IsUserProfileBusy())) { ErrorCode errorCode4 = User.RequestRemoteUserProfileForNpID(this.remoteNpID); if (errorCode4 != null) { ResultCode resultCode4 = default(ResultCode); User.GetLastUserProfileError(ref resultCode4); OnScreenLog.Add(string.Concat(new object[] { resultCode4.get_className(), ": ", resultCode4.lastError, ", sce error 0x", resultCode4.lastErrorSCE.ToString("X8") })); } } if (this.menuUser.AddBackIndex("Back", true)) { menuStack.PopMenu(); } }
public void MenuTus(MenuStack menuStack) { menuTus.Update(); bool enabled = User.IsSignedInPSN && !TusTss.IsTusBusy(); if (menuTus.AddItem("TUS Set Data", enabled)) { byte[] array = new byte[4]; for (int i = 0; i < 4; i++) { array[i] = (byte)(3 - i); } OnScreenLog.Add(" Data size: " + array.Length); string text = string.Empty; for (int j = 0; j < 16 && j < array.Length; j++) { text = text + array[j].ToString() + ", "; } OnScreenLog.Add(" Data: " + text); m_TUSDataRequestType = TUSDataRequestType.SaveRawData; ErrorHandler(TusTss.SetTusData(1, array)); } if (menuTus.AddItem("TUS Request Data", enabled)) { m_TUSDataRequestType = TUSDataRequestType.LoadRawData; ErrorHandler(TusTss.RequestTusData(1)); } if (menuTus.AddItem("TUS Save PlayerPrefs", enabled)) { PlayerPrefs.DeleteAll(); PlayerPrefs.SetInt("keyA", 1); PlayerPrefs.SetString("keyB", "Hello"); PlayerPrefs.SetInt("keyC", 3); PlayerPrefs.SetInt("keyD", 4); byte[] data = PSVitaPlayerPrefs.SaveToByteArray(); m_TUSDataRequestType = TUSDataRequestType.SavePlayerPrefs; ErrorHandler(TusTss.SetTusData(3, data)); } if (menuTus.AddItem("TUS Load PlayerPrefs", enabled)) { m_TUSDataRequestType = TUSDataRequestType.LoadPlayerPrefs; ErrorHandler(TusTss.RequestTusData(3)); } if (menuTus.AddItem("TUS Set Variables", enabled)) { ErrorHandler(TusTss.SetTusVariables(new TusTss.TusVariable[4] { new TusTss.TusVariable(1, 110L), new TusTss.TusVariable(2, 220L), new TusTss.TusVariable(3, 330L), new TusTss.TusVariable(4, 440L) })); } if (menuTus.AddItem("TUS Request Variables", enabled)) { int[] slotIDs = new int[4] { 1, 2, 3, 4 }; ErrorHandler(TusTss.RequestTusVariables(slotIDs)); } if (menuTus.AddItem("TUS Set Variables VU", enabled)) { ErrorHandler(TusTss.SetTusVariablesForVirtualUser(variables: new TusTss.TusVariable[1] { new TusTss.TusVariable(5, 12345L) }, onlineID: virtualUserOnlineID)); } if (menuTus.AddItem("TUS Request Variables VU", enabled)) { int[] slotIDs2 = new int[1] { 5 }; ErrorHandler(TusTss.RequestTusVariablesForVirtualUser(virtualUserOnlineID, slotIDs2)); } if (menuTus.AddItem("TUS Modify Variables VU", enabled)) { ErrorHandler(TusTss.ModifyTusVariablesForVirtualUser(variables: new TusTss.TusVariable[1] { new TusTss.TusVariable(5, 1L) }, onlineID: virtualUserOnlineID)); } if (menuTus.AddBackIndex("Back")) { menuStack.PopMenu(); } }
private void OnSessionCreated(Messages.PluginMessage msg) { OnScreenLog.Add("Commerce Session Created"); sessionCreated = true; }
private void OnProfileDialogClosed(Messages.PluginMessage msg) { Dialogs.NpDialogReturn dialogResult = Dialogs.GetDialogResult(); OnScreenLog.Add("Profile dialog closed with result: " + dialogResult.result); }