Why am I not connecting to Photon Chat but rather disconnecting
Hi I am trying to connect to Photon Chat but I am not able to connect to it. Rather I am getting disconnected. If I don't put the
if(chatclient!=null) chatclient.Service();
in the Update loop, it is not getting disconnected, but rather not getting connected as well. Well this is my code
using ExitGames.Client.Photon; using Photon.Chat; using Photon.Pun; void Start() { if (string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat)) Debug.Log("no CHat app ID provided"); ConnectToPhotonChat(); } private void ConnectToPhotonChat() { chatclient = new ChatClient(this); chatclient.ChatRegion="in"; chatclient.Connect(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat,PhotonNetwork.AppVersion, new Photon.Chat.AuthenticationValues(nickname)); Debug.Log("Connect to Photon Chat"); } void Update() { if(chatclient!=null) chatclient.Service();//in the update so that I constantly is connected and receiving messages } public void OnDisconnected() { Debug.Log("You have disconnected from the Photon Chat........"); } public void OnConnected() { Debug.Log("You have successfully connected to the Photon Chat......."); chatclient.SendPrivateMessage("chethan7", "INVITE......"); }
Actually speaking in the console "You have successfully connected to the Photon Chat.......",which is the one which gets executed when you successfully connect to Photon Chat should be executed.Here is the look of the console:
Best Answer
-
0
Answers
-
Is there no one to answer this?
0 -
0
-
Oh @JohnTube u saved my day. Thank u so so so.... much. Yeah it is working now. One question I have is , Is it Ok for PUN and chat to be on different servers?(I am just asking in case....)
0 -
Yes it's totally OK to use different regions in PUN and Photon Chat.
0 -
Thanks
1 -
Hello
0 -
I got stuck with this problem too. I found that i'm calling chatClient.Service() method in GameObject that is not active which is not correct. If you want to have a chat that needs to be active and passive (setActive(true) , setActive(false)), i recommend you to use two monobehaviour classes where one of them implements IChatClientListener and keeps alive PhotonChat session with chatClient.Service() within Update method, other one is only to game UI things like showing messages, toggling message panels and etc.
0