Chat Connected but OnSubscribed never is getting called

Hi.
Just as the title says, I'm connecting to the service, and in the callback I try to subscribe to a public channel but I never receive a callback for that. Chat doesn't work, but I guess it's because there is no subscription to any channel.

any clues of why this could be happening?

cheers

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Wolfy,

    Thank you for choosing Photon!

    How are you connecting and how are you subscribing? maybe a code snippet helps.
    What client SDK are you using? what version?
  • Wolfy
    Wolfy
    edited August 2019
    Hi @JohnTube ,
    thanks for the answer.

    I'm using the latest version from the AssetStore, in Unity 2019.1.4f1

    To connect I do:
    chatClient = new ChatClient(this);
    chatClient.ChatRegion = "US";
    var authValues = new AuthenticationValues();
    authValues.AuthType = CustomAuthenticationType.None;
    authValues.UserId = aname;
    
    chatClient.Connect(theAppID, "1.0", authValues);
    OnConnected callback is called right after, and there I do:

    chatClient.Subscribe("gamechannel");

    OnSubscribed is not called after that. Also chat doens't work (send/receive messages), but I assume that makes sense since the user is not subscribed to any channel.

    Thanks for the help!
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Wolfy,

    I'm using the latest version from the AssetStore

    Which package? as PhotonChatApi is included in all these: Does this happen with the demo scene?

    I could not reproduce.

    using System;
    using Photon.Chat;
    using ExitGames.Client.Photon;
    using UnityEngine;
    
    public class ChatSubscribeTest : MonoBehaviour, IChatClientListener
    {
        private ChatClient chatClient;
    
        [SerializeField]
        private string aname;
        [SerializeField]
        private string theAppID;
        [SerializeField]
        private string appVersion = "1.0";
        [SerializeField]
        private string channelName = "gamechannel";
        [SerializeField]
        private string region = "US";
    
        // Use this for initialization
        private void Start()
        {
            chatClient = new ChatClient(this);
            chatClient.ChatRegion = region;
            var authValues = new AuthenticationValues();
            authValues.AuthType = CustomAuthenticationType.None;
            authValues.UserId = aname;
            
            chatClient.Connect(theAppID, appVersion, authValues);
        }
    
        // Update is called once per frame
        private void Update()
        {
            if (chatClient != null)
            {
                chatClient.Service();
            }
        }
    
        public void DebugReturn(DebugLevel level, string message)
        {
        }
    
        public void OnDisconnected()
        {
        }
    
        public void OnConnected()
        {
            Debug.Log("OnConnected");
            chatClient.Subscribe("gamechannel");
        }
    
        public void OnChatStateChange(ChatState state)
        {
        }
    
        public void OnGetMessages(string channelName, string[] senders, object[] messages)
        {
        }
    
        public void OnPrivateMessage(string sender, object message, string channelName)
        {
        }
    
        public void OnSubscribed(string[] channels, bool[] results)
        {
            if (channels.Length == 1 && results[0] && channels[0].Equals(channelName, StringComparison.OrdinalIgnoreCase))
            {
                Debug.Log("Subscribed");
            }
        }
    
        public void OnUnsubscribed(string[] channels)
        {
        }
    
        public void OnStatusUpdate(string user, int status, bool gotMessage, object message)
        {
        }
    
        public void OnUserSubscribed(string channel, string user)
        {
        }
    
        public void OnUserUnsubscribed(string channel, string user)
        {
        }
    }



    Maybe you got disconnected before subscribe happens.
    Are you sure you got connected in the first place?
    Are you calling chatClient.Service() as expected?

    Could you try with a different:
    • User (userId)
    • AppVersion
    • AppId
    • Region
    • Channel name
    does private chat (private messages) work between users?