Why i can not connect to Photon chat ?

sawansawan
edited July 2016 in Photon Chat
I install Photon Chat from asset store and i tried to use the demo but its not make a connect (in the debug text still disconnected )
note : I live in Syria , is that maybe the reason of can not make a connect ?

Answers

  • Hi @sawan,

    In order to help you, please provide the following information:

    - the code you use to connect to Photon Chat.
    - Photon SDK you use and its version, target platform and game engine version if any.
    - logs if any (screenshot or text).

    N.B.: I hope your location is not a factor here and if I may, be safe!
  • sawansawan
    edited July 2016
    Thanks for replay @JohnTube :)
    first , this is the code that i tried to connect to Photon Chat :
    public void Start()
        {
            DontDestroyOnLoad(gameObject);
            this.ChatPanel.gameObject.SetActive(true);
            Application.runInBackground = true; // this must run in background or it will drop connection if not focussed.
            if (string.IsNullOrEmpty(UserName))
            {
                UserName = "user" + Environment.TickCount%99; //made-up username
            }
            this.chatClient = new ChatClient(this);
            string chatAppId = ChatSettings.Instance.AppId;
            this.chatClient.Connect(chatAppId, "1.0", new AuthenticationValues(UserName));
            this.ChannelToggleToInstantiate.gameObject.SetActive(false);
            Debug.Log("Connecting as: " + UserName);
        }
    And this "onConneted" function which is never called
    public void OnConnected()
        {
            Debug.Log("yeeees conected :) ");
            if (this.ChannelsToJoinOnConnect != null && this.ChannelsToJoinOnConnect.Length > 0)
            {
                this.chatClient.Subscribe(this.ChannelsToJoinOnConnect, this.HistoryLengthToFetch);
            }
        }
    About Photon SDK i work on Unity 3D SDK v4.1.0.4 , i don't modify anything (just in entered my AppID)
    I worked on unity 5.1.3 and i want to build my game on android and windows (windows not nessesary)
    When i run the project and tried to send message , this error appear
    "PublishMessage called while not connected to front end server."

    Thanks for your help :blush:
  • Please make sure to have this in your code to keep the connection alive and to get incoming messages.
    void Update(){
        chatClient.Service();
    }
  • @JohnTube I am also facing the same issue. When I am trying to send a private message to a user it's showing an error sendprivatemessage called while not connected to frontend server.
    I have connected to chat in one scene and it showed me connectedtofrontend but when I move to next scene and trying to send message it showed me that error. Is it because of scene changing? Please help me.
  • Hi @avimon,

    Maybe Photon chat client is disconnected during scene loading.
    Try connecting again after loading the scene.
    You can detect this in OnDisconnected method implemented in the listener.
    Maybe the listener needs to be attached to a GameObject that has DontDestroyOnLoad flag.
Sign In or Register to comment.