// Update is called once per frame void Update() { if (thisPlayer == null && FindObjectOfType <NetworkedManager>().inRoomAndInitialized == true) { thisPlayer = GameObject.Find((string)PhotonNetwork.player.CustomProperties["UniqueId"]); } if (socialActions == null && PhotonNetwork.inRoom == true && FindObjectOfType <NetworkedManager>().inRoomAndInitialized == true) { socialActions = thisPlayer.GetComponent <NetworkedSocial>(); client = thisPlayer.GetComponent <NetworkedClient>(); } if (client != null && client.FriendsStatus != null) { if (id.text == "Id" && name.text == "Name") { OnUpdateFriendsList(); idInputField.text = (string)PhotonNetwork.player.CustomProperties["UniqueId"]; name.text = PhotonNetwork.player.NickName; room.text = PhotonNetwork.room.Name; } } }
public void OnPrivateMessage(string sender, object message, string channelName) { if (sender == (string)PhotonNetwork.player.CustomProperties["UniqueId"] == true) { Debug.Log("THIS IS OUR PRIVATE MESSAGE"); return; } Status privateUpdate = new Status(message); Debug.Log(privateUpdate.Printable); Debug.Log(string.Format("OnPrivateMessages()\n{0} :: {1}\n{2}", sender, privateUpdate.Info, privateUpdate.Printable)); // byte[] msgBytes = message as byte[]; if (privateUpdate != null) { Debug.Log(privateUpdate.Info); string code = privateUpdate.Info; if (code == "PartyInvitationRequest") { // Handle when a player receives a party invite Invites.Add(privateUpdate); GameObject.Find("Player").GetComponent <InputHandler>().OnUpdateInvitesList(); } else if (code == "PartyJoinRequest") { socialActions = GetComponent <NetworkedSocial>(); Debug.Log(string.Format("PartyJoinRequest()\n{0}\n{1}\n{2}", (string)PhotonNetwork.player.CustomProperties["UniqueId"], socialActions, privateUpdate.Target)); // Handle when a player requests to join a party GetComponent <Party>().OnJoin(privateUpdate.Owner); } else if (code == "PartyJoinResponse") { // Handle when a player receives party join data socialActions.OnJoinedParty(privateUpdate.Owner, privateUpdate); } } }
public void InitClient() { socialActions = GetComponent <NetworkedSocial>(); //DontDestroyOnLoad(gameObject); if (string.IsNullOrEmpty(UserName)) { UserName = (string)PhotonNetwork.player.CustomProperties["UniqueId"]; } bool _AppIdPresent = string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.ChatAppID); if (string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.ChatAppID)) { Debug.LogError("You need to set the chat app ID in the PhotonServerSettings file in order to continue."); return; } if (PhotonNetwork.connectedAndReady) { Connect(); } }