SetOnlineStatus(int) | Not Setting Online

GLucas
GLucas
edited June 2019 in Photon Chat
Hi,

Just switched from PUN2 friends to Chat friends system. All is working great with chat except friends status update for some reason.

My system is as follows:
void DebugPlayerOnlineStatus() {
            if (Input.GetKeyDown(KeyCode.F1)) {
                chatClient.SetOnlineStatus(1);
            }
            if (Input.GetKeyDown(KeyCode.F2)) {
                chatClient.SetOnlineStatus(2);
            }
            if (Input.GetKeyDown(KeyCode.F3)) {
                chatClient.SetOnlineStatus(3);
            }
        }

(First i pressed F2, then F3, then finally, F1)
void IChatClientListener.OnStatusUpdate(string user, int status, bool gotMessage, object message) {
    Debug.LogError("<b>" + user + "</b> set online status to <b>(" + status + ") " + ReturnOnlineStatus(status) + "</b>" + (gotMessage ? (message != null ? message.ToString() : "") : ""));
}
Those responses are from the other client. However, it seems whenever the other client presses F1 key, it sends a 0 as the parameter which in turn returns what you see in the image.

Here is the return values for the int parameter:
public static string ReturnOnlineStatus(int status) {
            string onlineStatus = string.Empty;
            switch (status) {
                case 1:
                    onlineStatus = "Online";
                    break;
                case 2:
                    onlineStatus = "AFK";
                    break;
                case 3:
                    onlineStatus = "DND";
                    break;
                default:
                    onlineStatus = "Offline";
                    break;
            }
            return onlineStatus;
        }
I dont really know what im doing wrong here and why its not sending the online state.

(NOTE: There is no other code calling SetOnlineStatus(int) in my code, i cross-referenced in visual studio and the scene hierarchy itself)



Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @GLucas,

    Photon Chat has some reserved or special user status values like 0 (offline), 1 (invisible) and 2 (online).
    There is a class called ChatUserStatus with all predefined values.
    You can add other different custom ones of course.
  • Ah i see. That makes much more sense for some reason i didnt come across that in the setup documentation.