Example #1
0
    // Use this for initialization
    void Start()
    {
        enabled = gameObject.GetComponent <PhotonView>().isMine;
        if (!enabled)
        {
            return;
        }
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
        }
        nc          = GameObject.Find("NetworkHolder").GetComponent <NetworkController>();
        chatMenu    = GameObject.Find("Chat").GetComponent <ChatMenu>();
        chatMenu.ch = this;
        Username    = nc.PlayerLogin;
        ConnectionProtocol connectProtocol = ConnectionProtocol.Udp;

        chatclient            = new ChatClient(this, connectProtocol);
        chatclient.ChatRegion = "EU";
        authValues            = new ExitGames.Client.Photon.Chat.AuthenticationValues();
        authValues.UserId     = Username;
        authValues.AuthType   = ExitGames.Client.Photon.Chat.CustomAuthenticationType.None;
        instance = this;
        DontDestroyOnLoad(gameObject);
        Application.runInBackground = true;
        Connect();
    }
Example #2
0
    public void Connect()
    {
        var authValues = new ExitGames.Client.Photon.Chat.AuthenticationValues();

        authValues.UserId   = UserName;
        authValues.AuthType = ExitGames.Client.Photon.Chat.CustomAuthenticationType.None;
        chatClient.Connect(ChatSettings.Instance.AppId, "1.0", authValues);
    }
Example #3
0
 public void LoginChat(string username)
 {
     FindObjectOfType <PartyMatchmaker>().ClearParty();
     chatClient = new ChatClient(this, ExitGames.Client.Photon.ConnectionProtocol.Udp);
     ExitGames.Client.Photon.Chat.AuthenticationValues auth = new ExitGames.Client.Photon.Chat.AuthenticationValues();
     auth.UserId = username;
     chatClient.Connect(appID, "1.0", auth);
 }
Example #4
0
	public void LoginChat (string username) 
	{
		FindObjectOfType<PartyMatchmaker>().ClearParty();
		chatClient = new ChatClient( this , ExitGames.Client.Photon.ConnectionProtocol.Udp);
		ExitGames.Client.Photon.Chat.AuthenticationValues auth = new ExitGames.Client.Photon.Chat.AuthenticationValues();
		auth.UserId = username;
		chatClient.Connect( appID, "1.0", auth);
	}
Example #5
0
        public bool Connect(string appId, string appVersion, string userId, AuthenticationValues authValues)
        {
#if UNITY_WEBGL
            var protocol = ConnectionProtocol.WebSocketSecure;
#else
            var protocol = ConnectionProtocol.Udp;
#endif
            return(this.Connect(protocol, appId, appVersion, userId, authValues));
        }
        public bool Connect(string appId, string appVersion, string userId, AuthenticationValues authValues)
        {

#if UNITY_WEBGL
            var protocol = ConnectionProtocol.WebSocketSecure;
#else
            var protocol = ConnectionProtocol.Udp;
#endif
            return this.Connect(protocol, appId, appVersion, userId, authValues);

        }
Example #7
0
    private void Awake()
    {
        ExitGames.Client.Photon.ConnectionProtocol connectProtocol = ExitGames.Client.Photon.ConnectionProtocol.Udp;
        chatClient            = new ChatClient(this, connectProtocol);
        chatClient.ChatRegion = "Asia"; //anywhere else than US and europe

        ExitGames.Client.Photon.Chat.AuthenticationValues authValues = new ExitGames.Client.Photon.Chat.AuthenticationValues();
        authValues.UserId   = "uniqueUserNameHere";
        authValues.AuthType = ExitGames.Client.Photon.Chat.CustomAuthenticationType.None;

        chatClient.Connect("3a6c9000-dce8-4bc3-a4f9-c38378ace551", versionName, authValues);
    }
Example #8
0
        /// <summary>
        /// Connects chat client to the Photon Chat Cloud service, which will also authenticate the user (and set a UserId).
        /// </summary>
        /// <param name="authenticationValues">Values for authentication. You can leave this null, if you set a UserId before. If you set authValues, they will override any UserId set before.</param>
        /// <returns><c>true</c> if operations has succeed, otherwise <c>false</c>.</returns>
        public bool Connect(ExitGames.Client.Photon.Chat.AuthenticationValues authenticationValues = null)
        {
            if (string.IsNullOrEmpty(AppId))
            {
                Debug.LogError("Missing App Id! Please insert your App Id in Chat component to configure it properly.",
                               this);

                return(false);
            }

            return(_chatClient.Connect(AppId, AppVersion, authenticationValues));
        }
Example #9
0
 public void Connect()
 {
     if (PhotonNetwork.offlineMode)
     {
         return;
     }
     chatClient            = new ChatClient(this);
     chatClient.ChatRegion = "EU";
     ExitGames.Client.Photon.Chat.AuthenticationValues auth;
     auth = new ExitGames.Client.Photon.Chat.AuthenticationValues(Global.save.playerName);
     chatClient.Connect(chatAppID, Global.multiplayerVersion, auth);
 }
Example #10
0
        /// <summary>
        /// Connects this client to the Photon Chat Cloud service, which will also authenticate the user (and set a UserId).
        /// </summary>
        /// <param name="appId">Get your Photon Chat AppId from the <a href="https://www.photonengine.com/en/Chat/Dashboard">Dashboard</a>.</param>
        /// <param name="appVersion">Any version string you make up. Used to separate users and variants of your clients, which might be incompatible.</param>
        /// <param name="authValues">Values for authentication. You can leave this null, if you set a UserId before. If you set authValues, they will override any UserId set before.</param>
        /// <returns></returns>
        public bool Connect(string appId, string appVersion, AuthenticationValues authValues)
        {
            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause         = ChatDisconnectCause.None;

            if (authValues != null)
            {
                this.AuthValues = authValues;
                if (string.IsNullOrEmpty(this.AuthValues.UserId))
                {
                    if (this.DebugOut >= DebugLevel.ERROR)
                    {
                        this.listener.DebugReturn(DebugLevel.ERROR, "Connect failed: no UserId specified in authentication values.");
                    }
                    return(false);
                }
            }
            else
            {
                if (this.DebugOut >= DebugLevel.ERROR)
                {
                    this.listener.DebugReturn(DebugLevel.ERROR, "Connect failed: no authentication values specified");
                }
                return(false);
            }
            this.AppId           = appId;
            this.AppVersion      = appVersion;
            this.didAuthenticate = false;
            this.chatPeer.QuickResendAttempts = 2;
            this.chatPeer.SentCountAllowance  = 7;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();
            this.PublicChannelsUnsubscribing.Clear();

            this.NameServerAddress = this.chatPeer.NameServerAddress;
            bool isConnecting = this.chatPeer.Connect();

            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }

            if (this.UseBackgroundWorkerForSending)
            {
                SupportClass.StartBackgroundCalls(this.SendOutgoingInBackground, this.msDeltaForServiceCalls, "ChatClient Service Thread");
            }

            return(isConnecting);
        }
Example #11
0
    // Use this for initialization
    void Start()
    {
        Application.runInBackground = true;
        authValues            = new ExitGames.Client.Photon.Chat.AuthenticationValues();
        photonView            = this.GetComponent <PhotonView>();
        chatCanvas            = this.GetComponent <Canvas> ();
        chatClient            = new ChatClient(this, ExitGames.Client.Photon.ConnectionProtocol.Tcp);
        chatClient.ChatRegion = "US";
        authValues.UserId     = System.DateTime.UtcNow.ToString();
        chatClient.Connect("11d9264f-b5f0-41e7-b6b3-19b3476bcd0c", "0.1", authValues);

        authValues = new ExitGames.Client.Photon.Chat.AuthenticationValues();
    }
    public ChattingClient(UpdateUI ui)
    {
        Debug.Log("Start ChattingClient");
        this.ui = ui;
        ExitGames.Client.Photon.ConnectionProtocol connectProtocol = ExitGames.Client.Photon.ConnectionProtocol.Udp;
        chatClient            = new ChatClient(this, connectProtocol);
        chatClient.ChatRegion = "EU";

        ExitGames.Client.Photon.Chat.AuthenticationValues authValues = new ExitGames.Client.Photon.Chat.AuthenticationValues();
        authValues.UserId   = "uniqueUserName";
        authValues.AuthType = ExitGames.Client.Photon.Chat.CustomAuthenticationType.None;

        chatClient.Connect(/*"d12a70e0-dafa-4716-abf7-9ac2c39619d6"*/ "ebbf7b53-da3e-4247-931d-76a205592ee0", "0.1", authValues);
    }
Example #13
0
        void Start()
        {
            Instance       = this;
            _previousScene = 0;

            DontDestroyOnLoad(gameObject);

            UserName    = PhotonNetwork.playerName;
            ChannelName = "global#";
            RoomName    = "";

            chatClient = new ChatClient(this);

            chatClient.ChatRegion = "EU";
            ExitGames.Client.Photon.Chat.AuthenticationValues authValues = new ExitGames.Client.Photon.Chat.AuthenticationValues();
            authValues.UserId   = UserName;
            authValues.AuthType = ExitGames.Client.Photon.Chat.CustomAuthenticationType.None;
            chatClient.Connect(PhotonNetwork.PhotonServerSettings.ChatAppID, PhotonNetwork.gameVersion, authValues);
        }
Example #14
0
    public void GameChatConnect(string userName)
    {
        bool tryConnect = false;

        if (this.chatClient == null)
        {
            tryConnect = true;
        }
        else
        {
            if (this.chatClient.State != ChatState.ConnectedToFrontEnd &&
                this.chatClient.State != ChatState.ConnectingToFrontEnd &&
                this.chatClient.State != ChatState.ConnectedToNameServer &&
                this.chatClient.State != ChatState.ConnectingToNameServer)
            {
                tryConnect = true;
            }
            Debug.Log("GameChatConnect state: " + this.chatClient.State);
        }
        if (tryConnect)
        {
            nowConnecting    = true;
            chatDisconnected = false;
            this.chatClient  = new ChatClient(this);
            ExitGames.Client.Photon.Chat.AuthenticationValues authVals =
                new ExitGames.Client.Photon.Chat.AuthenticationValues(userName);
            authVals.AuthType = ExitGames.Client.Photon.Chat.CustomAuthenticationType.Custom;
            localPlayerId     = ZPlayerPrefs.GetString("playfabId");
            authVals.AddAuthParameter("username", localPlayerId);
            authVals.AddAuthParameter("token", ZPlayerPrefs.GetString("token"));

            this.chatClient.AuthValues = authVals;
            this.chatClient.ChatRegion = "EU";
            Debug.Log("Connect chat user: "******", id: " + localPlayerId + ", token: " + ZPlayerPrefs.GetString("token"));
            this.chatClient.Connect(PhotonNetwork.PhotonServerSettings.ChatAppID, MainMenu.GameVersion, authVals);
        }
        else
        {
            Debug.LogWarning("Chat already connected");
        }
    }
Example #15
0
    private void Connect()
    {
        Debug.Log("GAMECHAT: Connect");
        if (string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.ChatAppID))
        {
            print("No ChatAppID provided");
            return;
        }

        chatChannel = PhotonNetwork.room.Name + "CHANNEL";                      /*************  append room name *****************/
        Debug.Log("GAMECHAT: About to connect to chat");

        ExitGames.Client.Photon.ConnectionProtocol connectProtocol = ExitGames.Client.Photon.ConnectionProtocol.Udp;
        chatClient            = new ChatClient(this, connectProtocol);
        chatClient.ChatRegion = "Cae";
        ExitGames.Client.Photon.Chat.AuthenticationValues authValues = new ExitGames.Client.Photon.Chat.AuthenticationValues();
        authValues.UserId   = usernameText;
        authValues.AuthType = ExitGames.Client.Photon.Chat.CustomAuthenticationType.None;
        chatClient.Connect(PhotonNetwork.PhotonServerSettings.ChatAppID, "0.0.1", authValues);
        Debug.Log("GAMECHAT: Connected");
    }
Example #16
0
        public bool AuthenticateOnNameServer(string appId, string appVersion, string region, string userId, AuthenticationValues authValues)
        {
            if (this.DebugOut >= DebugLevel.INFO)
            {
                this.Listener.DebugReturn(DebugLevel.INFO, "OpAuthenticate()");
            }

            var opParameters = new Dictionary<byte, object>();

            opParameters[ParameterCode.AppVersion] = appVersion;
            opParameters[ParameterCode.ApplicationId] = appId;
            opParameters[ParameterCode.Region] = region;

            if (!string.IsNullOrEmpty(userId))
            {
                opParameters[ParameterCode.UserId] = userId;
            }

            if (authValues != null && authValues.AuthType != CustomAuthenticationType.None)
            {
                opParameters[ParameterCode.ClientAuthenticationType] = (byte)authValues.AuthType;
                if (!string.IsNullOrEmpty(authValues.Secret))
                {
                    opParameters[ParameterCode.Secret] = authValues.Secret;
                }
                else
                {
                    if (!string.IsNullOrEmpty(authValues.AuthParameters))
                    {
                        opParameters[ParameterCode.ClientAuthenticationParams] = authValues.AuthParameters;
                    }
                    if (authValues.AuthPostData != null)
                    {
                        opParameters[ParameterCode.ClientAuthenticationData] = authValues.AuthPostData;
                    }
                }
            }

            return this.OpCustom((byte)ChatOperationCode.Authenticate, opParameters, true, (byte)0, this.IsEncryptionAvailable);
        }
Example #17
0
        /// <summary>
        /// Connects this client to the Photon Chat Cloud service, which will also authenticate the user (and set a UserId).
        /// </summary>
        /// <param name="appId">Get your Photon Chat AppId from the <a href="https://www.photonengine.com/en/Chat/Dashboard">Dashboard</a>.</param>
        /// <param name="appVersion">Any version string you make up. Used to separate users and variants of your clients, which might be incompatible.</param>
        /// <param name="authValues">Values for authentication. You can leave this null, if you set a UserId before. If you set authValues, they will override any UserId set before.</param>
        /// <returns></returns>
        public bool Connect(string appId, string appVersion, AuthenticationValues authValues)
        {
            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause         = ChatDisconnectCause.None;

            if (authValues != null)
            {
                this.AuthValues = authValues;
                if (this.AuthValues.UserId == null || this.AuthValues.UserId == "")
                {
                    this.listener.DebugReturn(DebugLevel.ERROR, "Connect failed: no UserId specified in authentication values");
                    return(false);
                }
            }
            else
            {
                this.listener.DebugReturn(DebugLevel.ERROR, "Connect failed: no authentication values specified");
                return(false);
            }
            this.AppId                        = appId;
            this.AppVersion                   = appVersion;
            this.didAuthenticate              = false;
            this.msDeltaForServiceCalls       = 100;
            this.chatPeer.QuickResendAttempts = 2;
            this.chatPeer.SentCountAllowance  = 7;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            this.NameServerAddress = this.chatPeer.NameServerAddress;
            bool isConnecting = this.chatPeer.Connect();

            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return(isConnecting);
        }
Example #18
0
 public bool Connect(string appId, string appVersion, AuthenticationValues authValues)
 {
     this.chatPeer.TimePingInterval = (__Null)3000;
     this.DisconnectedCause         = ChatDisconnectCause.None;
     if (authValues != null)
     {
         this.AuthValues = authValues;
         if (this.AuthValues.UserId == null || this.AuthValues.UserId == string.Empty)
         {
             if (this.DebugOut >= 1)
             {
                 this.listener.DebugReturn((DebugLevel)1, "Connect failed: no UserId specified in authentication values");
             }
             return(false);
         }
         this.AppId                  = appId;
         this.AppVersion             = appVersion;
         this.didAuthenticate        = false;
         this.msDeltaForServiceCalls = 100;
         this.chatPeer.set_QuickResendAttempts((byte)2);
         this.chatPeer.SentCountAllowance = (__Null)7;
         this.PublicChannels.Clear();
         this.PrivateChannels.Clear();
         this.PublicChannelsUnsubscribing.Clear();
         this.NameServerAddress = this.chatPeer.NameServerAddress;
         bool flag = this.chatPeer.Connect();
         if (flag)
         {
             this.State = ChatState.ConnectingToNameServer;
         }
         return(flag);
     }
     if (this.DebugOut >= 1)
     {
         this.listener.DebugReturn((DebugLevel)1, "Connect failed: no authentication values specified");
     }
     return(false);
 }
        public bool Connect(ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
		{
#if UNITY_WEBGL
	        if (protocol != ConnectionProtocol.WebSocket && protocol != ConnectionProtocol.WebSocketSecure) {
				UnityEngine.Debug.Log("WebGL only supports WebSocket protocol. Overriding ChatClient.Connect() 'protocol' parameter");
				protocol = ConnectionProtocol.WebSocketSecure;
			}
#endif
            if (!this.HasPeer)
            {
                this.chatPeer = new ChatPeer(this, protocol);
            }
            else
            {
                this.Disconnect();
                if (this.chatPeer.UsedProtocol != protocol)
                {
                    this.chatPeer = new ChatPeer(this, protocol);
                }
            }

            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause = ChatDisconnectCause.None;

            this.CustomAuthenticationValues = authValues;
            this.UserId = userId;
            this.AppId = appId;
            this.AppVersion = appVersion;
            this.didAuthenticate = false;
            this.msDeltaForServiceCalls = 100;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            bool isConnecting = this.chatPeer.Connect();
            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return isConnecting;
        }
 void Connect()
 {
     ExitGames.Client.Photon.Chat.AuthenticationValues authentication = new ExitGames.Client.Photon.Chat.AuthenticationValues();
     authentication.UserId = PlayFabDataStore.characterName;
     chatClient.Connect(photonChatId, photonAppVersion, authentication);
 }
Example #21
0
        /// <summary>
        /// Connects this client to the Photon Chat Cloud service, which will also authenticate the user (and set a UserId).
        /// </summary>
        /// <param name="appId">Get your Photon Chat AppId from the <a href="https://www.photonengine.com/en/Chat/Dashboard">Dashboard</a>.</param>
        /// <param name="appVersion">Any version string you make up. Used to separate users and variants of your clients, which might be incompatible.</param>
        /// <param name="authValues">Values for authentication. You can leave this null, if you set a UserId before. If you set authValues, they will override any UserId set before.</param>
        /// <returns></returns>
        public bool Connect(string appId, string appVersion, AuthenticationValues authValues)
		{
            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause = ChatDisconnectCause.None;

            if (authValues != null)
            {
                this.AuthValues = authValues;
                if (this.AuthValues.UserId == null || this.AuthValues.UserId == "")
                {
                    this.listener.DebugReturn(DebugLevel.ERROR, "Connect failed: no UserId specified in authentication values");
                    return false;
                }
            }
            else
            {
                this.listener.DebugReturn(DebugLevel.ERROR, "Connect failed: no authentication values specified");
                return false;
            }
            this.AppId = appId;
            this.AppVersion = appVersion;
            this.didAuthenticate = false;
            this.msDeltaForServiceCalls = 100;
            this.chatPeer.QuickResendAttempts = 2;
            this.chatPeer.SentCountAllowance = 7;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            this.NameServerAddress = this.chatPeer.NameServerAddress;
            bool isConnecting = this.chatPeer.Connect();
            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return isConnecting;
        }
Example #22
0
        // Token: 0x06003FA9 RID: 16297 RVA: 0x001400C8 File Offset: 0x0013E4C8
        public bool AuthenticateOnNameServer(string appId, string appVersion, string region, AuthenticationValues authValues)
        {
            if (this.DebugOut >= DebugLevel.INFO)
            {
                base.Listener.DebugReturn(DebugLevel.INFO, "OpAuthenticate()");
            }
            Dictionary <byte, object> dictionary = new Dictionary <byte, object>();

            dictionary[220] = appVersion;
            dictionary[224] = appId;
            dictionary[210] = region;
            if (authValues != null)
            {
                if (!string.IsNullOrEmpty(authValues.UserId))
                {
                    dictionary[225] = authValues.UserId;
                }
                if (authValues != null && authValues.AuthType != CustomAuthenticationType.None)
                {
                    dictionary[217] = (byte)authValues.AuthType;
                    if (!string.IsNullOrEmpty(authValues.Token))
                    {
                        dictionary[221] = authValues.Token;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(authValues.AuthGetParameters))
                        {
                            dictionary[216] = authValues.AuthGetParameters;
                        }
                        if (authValues.AuthPostData != null)
                        {
                            dictionary[214] = authValues.AuthPostData;
                        }
                    }
                }
            }
            return(this.OpCustom(230, dictionary, true, 0, base.IsEncryptionAvailable));
        }
Example #23
0
        public bool Connect(string address, ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
        {
            if (!this.HasPeer)
            {
                this.chatPeer = new ChatPeer(this, protocol);
            }
            else
            {
                this.Disconnect();
                if (this.chatPeer.UsedProtocol != protocol)
                {
                    this.chatPeer = new ChatPeer(this, protocol);
                }
            }

#if UNITY
#pragma warning disable 0162    // the library variant defines if we should use PUN's SocketUdp variant (at all)
            if (PhotonPeer.NoSocket)
            {
#if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
                UnityEngine.Debug.Log("Using class SocketUdpNativeDynamic");
                this.chatPeer.SocketImplementation = typeof(SocketUdpNativeDynamic);
#elif !UNITY_EDITOR && UNITY_IPHONE
                UnityEngine.Debug.Log("Using class SocketUdpNativeStatic");
                this.chatPeer.SocketImplementation = typeof(SocketUdpNativeStatic);
#elif !UNITY_EDITOR && (UNITY_WINRT)
                // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
#else
                Type udpSocket = Type.GetType("ExitGames.Client.Photon.SocketUdp, Assembly-CSharp");
                this.chatPeer.SocketImplementation = udpSocket;
                if (udpSocket == null)
                {
                    UnityEngine.Debug.Log("ChatClient could not find a suitable C# socket class. The Photon3Unity3D.dll only supports native socket plugins.");
                }
#endif
                if (this.chatPeer.SocketImplementation == null)
                {
                    UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
                }
            }
#pragma warning restore 0162
#endif

            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause         = ChatDisconnectCause.None;

            this.CustomAuthenticationValues = authValues;
            this.UserId                 = userId;
            this.AppId                  = appId;
            this.AppVersion             = appVersion;
            this.didAuthenticate        = false;
            this.msDeltaForServiceCalls = 100;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            if (!address.Contains(":"))
            {
                int port = 0;
                ProtocolToNameServerPort.TryGetValue(protocol, out port);
                address = string.Format("{0}:{1}", address, port);
            }

            bool isConnecting = this.chatPeer.Connect(address, "NameServer");
            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return(isConnecting);
        }
Example #24
0
 public bool Connect(string appId, string appVersion, string userId, AuthenticationValues authValues)
 {
     return(this.Connect(this.NameServerAddress, ConnectionProtocol.Udp, appId, appVersion, userId, authValues));
 }
Example #25
0
        public bool Connect(string address, ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
        {
            if (!this.HasPeer)
            {
                this.chatPeer = new ChatPeer(this, protocol);
            }
            else
            {
                this.Disconnect();
                if (this.chatPeer.UsedProtocol != protocol)
                {
                    this.chatPeer = new ChatPeer(this, protocol);
                }
            }

#if UNITY
#pragma warning disable 0162    // the library variant defines if we should use PUN's SocketUdp variant (at all)
            if (PhotonPeer.NoSocket)
            {
#if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
                UnityEngine.Debug.Log("Using class SocketUdpNativeDynamic");
                this.chatPeer.SocketImplementation = typeof(SocketUdpNativeDynamic);
#elif !UNITY_EDITOR && UNITY_IPHONE
                UnityEngine.Debug.Log("Using class SocketUdpNativeStatic");
                this.chatPeer.SocketImplementation = typeof(SocketUdpNativeStatic);
#elif !UNITY_EDITOR && (UNITY_WINRT)
                // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
#else
                Type udpSocket = Type.GetType("ExitGames.Client.Photon.SocketUdp, Assembly-CSharp");
                this.chatPeer.SocketImplementation = udpSocket;
                if (udpSocket == null)
                {
                    UnityEngine.Debug.Log("ChatClient could not find a suitable C# socket class. The Photon3Unity3D.dll only supports native socket plugins.");
                }
#endif
                if (this.chatPeer.SocketImplementation == null)
                {
                    UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
                }
            }
#pragma warning restore 0162
#endif

            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause = ChatDisconnectCause.None;

            this.CustomAuthenticationValues = authValues;
            this.UserId = userId;
            this.AppId = appId;
            this.AppVersion = appVersion;
            this.didAuthenticate = false;
            this.msDeltaForServiceCalls = 100;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            if (!address.Contains(":"))
            {
                int port = 0;
                ProtocolToNameServerPort.TryGetValue(protocol, out port);
                address = string.Format("{0}:{1}", address, port);
            }

            bool isConnecting = this.chatPeer.Connect(address, "NameServer");
            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return isConnecting;
        }
Example #26
0
        public bool Connect(string address, ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
        {
            if (!this.HasPeer)
            {
                this.chatPeer = new ChatPeer(this, protocol);
            }
            else
            {
                this.Disconnect();
                if (this.chatPeer.UsedProtocol != protocol)
                {
                    this.chatPeer = new ChatPeer(this, protocol);
                }
            }
            
            this.DisconnectedCause = ChatDisconnectCause.None;

            this.CustomAuthenticationValues = authValues;
            this.UserId = userId;
            this.AppId = appId;
            this.AppVersion = appVersion;
            this.didAuthenticate = false;
            this.msDeltaForServiceCalls = 100;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            if (!address.Contains(":"))
            {
                int port = 0;
                ProtocolToNameServerPort.TryGetValue(protocol, out port);
                address = string.Format("{0}:{1}", address, port);
            }

            bool isConnecting = this.chatPeer.Connect(address, "NameServer");
            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return isConnecting;
        }
        /// <summary> Authenticates on NameServer. </summary>
        /// <returns>If the authentication operation request could be sent.</returns>
        public bool AuthenticateOnNameServer(string appId, string appVersion, string region, AuthenticationValues authValues)
        {
            if (this.DebugOut >= DebugLevel.INFO)
            {
                this.Listener.DebugReturn(DebugLevel.INFO, "OpAuthenticate()");
            }

            var opParameters = new Dictionary <byte, object>();

            opParameters[ParameterCode.AppVersion]    = appVersion;
            opParameters[ParameterCode.ApplicationId] = appId;
            opParameters[ParameterCode.Region]        = region;

            if (authValues != null)
            {
                if (!string.IsNullOrEmpty(authValues.UserId))
                {
                    opParameters[ParameterCode.UserId] = authValues.UserId;
                }

                if (authValues != null && authValues.AuthType != CustomAuthenticationType.None)
                {
                    opParameters[ParameterCode.ClientAuthenticationType] = (byte)authValues.AuthType;
                    if (!string.IsNullOrEmpty(authValues.Token))
                    {
                        opParameters[ParameterCode.Secret] = authValues.Token;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(authValues.AuthGetParameters))
                        {
                            opParameters[ParameterCode.ClientAuthenticationParams] = authValues.AuthGetParameters;
                        }
                        if (authValues.AuthPostData != null)
                        {
                            opParameters[ParameterCode.ClientAuthenticationData] = authValues.AuthPostData;
                        }
                    }
                }
            }

            SendOptions sendOptions = new SendOptions
            {
                Reliability = true,
                Channel     = 0,
                Encrypt     = this.IsEncryptionAvailable
            };

            return(this.SendOperation(ChatOperationCode.Authenticate, opParameters, sendOptions));
        }
Example #28
0
 public bool Connect(string appId, string appVersion, string userId, AuthenticationValues authValues)
 {
     return this.Connect(this.NameServerAddress, ConnectionProtocol.Udp, appId, appVersion, userId, authValues);
 }
Example #29
0
        public bool Connect(string address, ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
        {
            if (!this.HasPeer)
            {
                this.chatPeer = new ChatPeer(this, protocol);
            }
            else
            {
                this.Disconnect();
                if (this.chatPeer.UsedProtocol != protocol)
                {
                    this.chatPeer = new ChatPeer(this, protocol);
                }
            }

            // #pragma warning disable 0162    // the library variant defines if we should use PUN's SocketUdp variant (at all)
            //             if (PhotonPeer.NoSocket)
            //             {
            // #if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
            //                 UnityEngine.Debug.Log("Chat uses class SocketUdpNativeDynamic");
            //                 this.chatPeer.SocketImplementation = typeof(SocketUdpNativeDynamic);
            // #elif !UNITY_EDITOR && UNITY_IPHONE
            //                 UnityEngine.Debug.Log("Chat uses class SocketUdpNativeStatic");
            //                 this.chatPeer.SocketImplementation = typeof(SocketUdpNativeStatic);
            // #elif !UNITY_EDITOR && (UNITY_WINRT || UNITY_WP8)
            //                 // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
            // #else
            //                 UnityEngine.Debug.Log("Chat uses class SocketUdp (default)");
            //                 this.chatPeer.SocketImplementation = typeof(SocketUdp);
            //                 // PhotonHandler.PingImplementation defaults to PingMono
            // #endif
            //
            //                 if (this.chatPeer.SocketImplementation == null)
            //                 {
            //                     UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
            //                 }
            //             }
            // #pragma warning restore 0162

            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause = ChatDisconnectCause.None;

            this.CustomAuthenticationValues = authValues;
            this.UserId = userId;
            this.AppId = appId;
            this.AppVersion = appVersion;
            this.didAuthenticate = false;
            this.msDeltaForServiceCalls = 100;

            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            if (!address.Contains(":"))
            {
                int port = 0;
                ProtocolToNameServerPort.TryGetValue(protocol, out port);
                address = string.Format("{0}:{1}", address, port);
            }

            bool isConnecting = this.chatPeer.Connect(address, "NameServer");
            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return isConnecting;
        }
Example #30
0
        public bool AuthenticateOnNameServer(string appId, string appVersion, string region, AuthenticationValues authValues)
        {
            if (this.DebugOut >= 3)
            {
                base.get_Listener().DebugReturn(3, "OpAuthenticate()");
            }
            Dictionary <byte, object> dictionary = new Dictionary <byte, object>();

            dictionary.set_Item(220, appVersion);
            dictionary.set_Item(224, appId);
            dictionary.set_Item(210, region);
            if (authValues != null)
            {
                if (!string.IsNullOrEmpty(authValues.UserId))
                {
                    dictionary.set_Item(225, authValues.UserId);
                }
                if (authValues != null && authValues.AuthType != CustomAuthenticationType.None)
                {
                    dictionary.set_Item(217, (byte)authValues.AuthType);
                    if (!string.IsNullOrEmpty(authValues.Token))
                    {
                        dictionary.set_Item(221, authValues.Token);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(authValues.AuthGetParameters))
                        {
                            dictionary.set_Item(216, authValues.AuthGetParameters);
                        }
                        if (authValues.AuthPostData != null)
                        {
                            dictionary.set_Item(214, authValues.AuthPostData);
                        }
                    }
                }
            }
            return(this.OpCustom(230, dictionary, true, 0, base.get_IsEncryptionAvailable()));
        }
Example #31
0
        public bool AuthenticateOnNameServer(string appId, string appVersion, string region, string userId, AuthenticationValues authValues)
        {
            if (this.DebugOut >= DebugLevel.INFO)
            {
                this.Listener.DebugReturn(DebugLevel.INFO, "OpAuthenticate()");
            }

            var opParameters = new Dictionary <byte, object>();

            opParameters[ParameterCode.AppVersion]    = appVersion;
            opParameters[ParameterCode.ApplicationId] = appId;
            opParameters[ParameterCode.Region]        = region;

            if (!string.IsNullOrEmpty(userId))
            {
                opParameters[ParameterCode.UserId] = userId;
            }

            if (authValues != null && authValues.AuthType != CustomAuthenticationType.None)
            {
                opParameters[ParameterCode.ClientAuthenticationType] = (byte)authValues.AuthType;
                if (!string.IsNullOrEmpty(authValues.Secret))
                {
                    opParameters[ParameterCode.Secret] = authValues.Secret;
                }
                else
                {
                    if (!string.IsNullOrEmpty(authValues.AuthParameters))
                    {
                        opParameters[ParameterCode.ClientAuthenticationParams] = authValues.AuthParameters;
                    }
                    if (authValues.AuthPostData != null)
                    {
                        opParameters[ParameterCode.ClientAuthenticationData] = authValues.AuthPostData;
                    }
                }
            }

            return(this.OpCustom((byte)ChatOperationCode.Authenticate, opParameters, true, (byte)0, this.IsEncryptionAvailable));
        }
Example #32
0
 public void Connect(ExitGames.Client.Photon.Chat.AuthenticationValues authenticationValues)
 {
     Chat.Instance.Connect(authenticationValues);
 }
Example #33
0
        /// <summary>
        /// Connects this client to the Photon Chat Cloud service, which will also authenticate the user (and set a UserId).
        /// </summary>
        /// <param name="appId">Get your Photon Chat AppId from the <a href="https://www.photonengine.com/en/Chat/Dashboard">Dashboard</a>.</param>
        /// <param name="appVersion">Any version string you make up. Used to separate users and variants of your clients, which might be incompatible.</param>
        /// <param name="authValues">Values for authentication. You can leave this null, if you set a UserId before. If you set authValues, they will override any UserId set before.</param>
        /// <returns></returns>
        public bool Connect(string appId, string appVersion, AuthenticationValues authValues)
		{
            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause = ChatDisconnectCause.None;

            if (authValues != null)
            {
                this.AuthValues = authValues;
            }
            this.AppId = appId;
            this.AppVersion = appVersion;
            this.didAuthenticate = false;
            this.msDeltaForServiceCalls = 100;
            this.chatPeer.QuickResendAttempts = 2;
            this.chatPeer.SentCountAllowance = 7;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            this.NameServerAddress = this.chatPeer.NameServerAddress;
            bool isConnecting = this.chatPeer.Connect();
            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return isConnecting;
        }
Example #34
0
        public bool Connect(ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
        {
#if UNITY_WEBGL
            if (protocol != ConnectionProtocol.WebSocket && protocol != ConnectionProtocol.WebSocketSecure)
            {
                UnityEngine.Debug.Log("WebGL only supports WebSocket protocol. Overriding ChatClient.Connect() 'protocol' parameter");
                protocol = ConnectionProtocol.WebSocketSecure;
            }
#endif
            if (!this.HasPeer)
            {
                this.chatPeer = new ChatPeer(this, protocol);
            }
            else
            {
                this.Disconnect();
                if (this.chatPeer.UsedProtocol != protocol)
                {
                    this.chatPeer = new ChatPeer(this, protocol);
                }
            }

            this.chatPeer.TimePingInterval = 3000;
            this.DisconnectedCause         = ChatDisconnectCause.None;

            this.CustomAuthenticationValues = authValues;
            this.UserId                 = userId;
            this.AppId                  = appId;
            this.AppVersion             = appVersion;
            this.didAuthenticate        = false;
            this.msDeltaForServiceCalls = 100;


            // clean all channels
            this.PublicChannels.Clear();
            this.PrivateChannels.Clear();

            bool isConnecting = this.chatPeer.Connect();
            if (isConnecting)
            {
                this.State = ChatState.ConnectingToNameServer;
            }
            return(isConnecting);
        }