Example #1
0
    //IChatClientListener
    public void OnPrivateMessage(string sender, object message, string channelName)
    {
        string[] MSG = (string[])message;

        if (MSG.Length > 0)
        {
            string MSGType = MSG[0];
            string SenderName;
            if (MSGType.Equals("Request"))
            {
                SenderName = MSG[2];

                SENDER_ID   = MSG[1];
                RECIEVER_ID = MSG[3];
                ROOM_NAME   = MSG[4];

                if (RECIEVER_ID.Equals(PlayerVariables.Inistance.getUserPlayFabID()))
                {
                    PanelRequests.SetActive(true);
                    PanelDialog.SetActive(true);
                    PlayerNameUIText.text = SenderName.Equals("") ? SENDER_ID : SenderName;
                }
            }
            else if (MSGType.Equals("Response"))
            {
                SenderName  = MSG[2];
                SENDER_ID   = MSG[1];
                RECIEVER_ID = MSG[3];
                string ResponseType = MSG[4];

                if (RECIEVER_ID.Equals(PlayerVariables.Inistance.getUserPlayFabID()))
                {
                    if (ResponseType.Equals("NO"))
                    {
                        ShowLoading = false;
                        LoadingImage.SetActive(false);
                        PanelRequests.SetActive(false);

                        if (SenderName.Equals(""))
                        {
                            if (PlayerPrefs.GetString("Language", "EN").Equals("EN"))
                            {
                                StartCoroutine(GeneralController.Inistance.ToastDisplayer("Player " + SENDER_ID + " Refused Your Request"));
                            }
                            else
                            {
                                StartCoroutine(GeneralController.Inistance.ToastDisplayer("ﺐﻋﻼﻟﺍ " + SENDER_ID + " ﻚﺒﻠﻃ ﺾﻓﺭ"));
                            }
                        }
                        else
                        {
                            if (PlayerPrefs.GetString("Language", "EN").Equals("EN"))
                            {
                                StartCoroutine(GeneralController.Inistance.ToastDisplayer("Player " + SenderName + " Refused Your Request"));
                            }
                            else
                            {
                                StartCoroutine(GeneralController.Inistance.ToastDisplayer("ﺐﻋﻼﻟﺍ " + SenderName + " ﻚﺒﻠﻃ ﺾﻓﺭ"));
                            }
                        }
                    }
                    else if (ResponseType.Equals("YES"))
                    {
                        CreateOrJoinRoom(true);
                    }
                }
            }
        }
    }
 /// <summary>
 /// Checks whether the <see cref="Message"/> comes from a <see cref="User"/> or from the Epistle server directly.<para> </para>
 /// Server messages come in the following format: <para> </para>
 /// <c>server:0:f12218f6b9e3481d964a109333f70ae7</c><para> </para>
 /// Message type IDs: <para> </para>
 /// 0 = User joined a convo.
 /// 1 = User left a convo.
 /// 2 = User was kicked out from a convo.
 /// 3 = The convo is about to expire (less than 24h left).
 /// 4 = The convo's metadata was changed.
 /// </summary>
 public bool IsFromServer()
 {
     return(SenderId == "0" && SenderName.Equals("Server", StringComparison.InvariantCultureIgnoreCase) && EncryptedBody.StartsWith("server:", StringComparison.InvariantCultureIgnoreCase));
 }