private void OnMatchingUpdatedSession(Messages.PluginMessage msg) { Matching.GetSessionInformationPtr(); OnScreenLog.Add("Session info updated..."); Matching.Session session = Matching.GetSession(); DumpSessionInfo(session); if (!InitializeHostAndSelf(session)) { OnScreenLog.Add("ERROR: Expected members not found!"); } if (Matching.IsHost) { return; } Matching.SessionMemberInfo?sessionMemberInfo = connected; if (sessionMemberInfo.HasValue) { return; } Matching.SessionMemberInfo value = host.Value; if (value.addr == 0) { OnScreenLog.Add("Unable to retrieve host IP address"); ErrorHandler(Matching.LeaveSession()); return; } Matching.SessionMemberInfo value2 = host.Value; string text = IntIPToIPString(value2.addr); object[] obj = new object[6] { "Connecting to ", text, ":", serverPort, " using signalling port:", null }; Matching.SessionMemberInfo value3 = host.Value; obj[5] = value3.port; OnScreenLog.Add(string.Concat(obj)); NetworkConnectionError networkConnectionError = Network.Connect(text, serverPort); if (networkConnectionError != 0) { OnScreenLog.Add("Connection failed: " + networkConnectionError); return; } OnScreenLog.Add("Connected to host " + text + " : " + serverPort); connected = host; }
private void OnMatchingUpdatedSession(Messages.PluginMessage msg) { IntPtr sessionInformationPtr = Matching.GetSessionInformationPtr(); OnScreenLog.Add("Session info updated..."); Matching.Session session = Matching.GetSession(); this.DumpSessionInfo(session); if (!this.InitializeHostAndSelf(session)) { OnScreenLog.Add("ERROR: Expected members not found!"); } if (!Matching.get_IsHost()) { Matching.SessionMemberInfo?sessionMemberInfo = this.connected; if (!sessionMemberInfo.get_HasValue()) { if (this.host.get_Value().addr == 0) { OnScreenLog.Add("Unable to retrieve host IP address"); this.ErrorHandler(Matching.LeaveSession()); return; } string text = this.IntIPToIPString(this.host.get_Value().addr); OnScreenLog.Add(string.Concat(new object[] { "Connecting to ", text, ":", this.serverPort, " using signalling port:", this.host.get_Value().port })); NetworkConnectionError networkConnectionError = Network.Connect(text, this.serverPort); if (networkConnectionError != null) { OnScreenLog.Add("Connection failed: " + networkConnectionError); } else { OnScreenLog.Add(string.Concat(new object[] { "Connected to host ", text, " : ", this.serverPort })); this.connected = this.host; } } } }
private void OnMatchingCreatedSession(Messages.PluginMessage msg) { OnScreenLog.Add("Created session..."); Matching.Session session = Matching.GetSession(); DumpSessionInfo(session); if (!InitializeHostAndSelf(session)) { OnScreenLog.Add("ERROR: Expected members not found!"); } NetworkConnectionError networkConnectionError = Network.InitializeServer(serverMaxConnections, serverPort, false); if (networkConnectionError != 0) { OnScreenLog.Add("Server err: " + networkConnectionError); } else { OnScreenLog.Add("Started Server"); } }
public void MenuMessaging(MenuStack menuStack) { menuMessaging.Update(); if (menuMessaging.AddItem("Show Messages & Invites", User.IsSignedInPSN && !Messaging.IsBusy())) { Messaging.ShowRecievedDataMessageDialog(); } if (menuMessaging.AddItem("Send Session Invite", User.IsSignedInPSN && Matching.InSession)) { string text = "Join my session"; int npIDCount = 8; Matching.InviteToSession(text, npIDCount); } if (menuMessaging.AddItem("Send Game Invite", User.IsSignedInPSN && !Messaging.IsBusy())) { GameInviteData gameInviteData = new GameInviteData(); gameInviteData.taunt = "I got an awesome score, can you do better?"; gameInviteData.level = 1; gameInviteData.score = 123456789; byte[] data = gameInviteData.WriteToBuffer(); Messaging.MsgRequest msgRequest = new Messaging.MsgRequest(); msgRequest.body = "Game invite"; msgRequest.expireMinutes = 30; msgRequest.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.streamingAssetsPath + "/PSP2SessionImage.jpg"; Messaging.SendMessage(msgRequest); } if (menuMessaging.AddItem("Send Data Message", User.IsSignedInPSN && !Messaging.IsBusy())) { GameData gameData = default(GameData); gameData.text = "Here's some data"; gameData.item1 = 2; gameData.item2 = 987654321; byte[] data2 = gameData.WriteToBuffer(); Messaging.MsgRequest msgRequest2 = new Messaging.MsgRequest(); msgRequest2.body = "Data message"; msgRequest2.expireMinutes = 0; msgRequest2.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.streamingAssetsPath + "/PSP2SessionImage.jpg"; Messaging.SendMessage(msgRequest2); } if (menuMessaging.AddItem("Send In Game Data (Session)", Matching.InSession && !Messaging.IsBusy())) { Matching.Session session = Matching.GetSession(); Matching.SessionMemberInfo[] members = session.members; if (members == null) { return; } int num = -1; for (int i = 0; i < members.Length; i++) { if ((members[i].memberFlag & Matching.FlagMemberType.MEMBER_MYSELF) == 0) { num = i; break; } } if (num >= 0) { OnScreenLog.Add("Sending in game data message to " + members[num].npOnlineID); GameData gameData2 = default(GameData); gameData2.text = "Here's some data"; gameData2.item1 = 2; gameData2.item2 = 987654321; byte[] data3 = gameData2.WriteToBuffer(); Messaging.SendInGameDataMessage(members[num].npID, data3); } else { OnScreenLog.Add("No session member to send to."); } } if (menuMessaging.AddItem("Send In Game Message (Friend)", User.IsSignedInPSN && !Messaging.IsBusy())) { Friends.Friend[] cachedFriendsList = Friends.GetCachedFriendsList(); if (cachedFriendsList.Length > 0) { int num2 = 0; if (num2 >= 0) { OnScreenLog.Add("Sending in game data message to " + cachedFriendsList[num2].npOnlineID); GameData gameData3 = default(GameData); gameData3.text = "Here's some data"; gameData3.item1 = 2; gameData3.item2 = 987654321; byte[] data4 = gameData3.WriteToBuffer(); Messaging.SendInGameDataMessage(cachedFriendsList[num2].npID, data4); } else { OnScreenLog.Add("No friends in this context."); } } else { OnScreenLog.Add("No friends cached."); OnScreenLog.Add("refresh the friends list then try again."); } } if (menuMessaging.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()); } }
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(); } }
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()); } }