public PhotonPeer(PeerConnectionInformation serverConnectionInformation,
                          ConnectionProtocol connectionProtocol, DebugLevel debugLevel, ICoroutinesExecutor coroutinesExecuter)
        {
            NetworkTrafficState = NetworkTrafficState.Flowing;

            this.serverConnectionInformation = serverConnectionInformation;

            RawPeer = new ExitGames.Client.Photon.PhotonPeer(this, connectionProtocol)
            {
                ChannelCount = 4
            };

            #if UNITY_WEBGL || UNITY_XBOXONE || WEBSOCKET
            if (connectionProtocol == ConnectionProtocol.WebSocket ||
                connectionProtocol == ConnectionProtocol.WebSocketSecure)
            {
                var websocketType = typeof(SocketWebTcpCoroutine);
                RawPeer.SocketImplementationConfig[ConnectionProtocol.WebSocket] = websocketType;
            }
            #endif

            RawPeer.DebugOut = debugLevel;

            coroutinesExecuter.StartCoroutine(UpdateEngine());

            eventsBuffer             = new Queue <RawMessageData>(10);
            operationResponsesBuffer = new Queue <Tuple <RawMessageResponseData, short> >(10);
            optionsBuffer            = new Queue <BufferOption>(10);
        }
Example #2
0
        //public Session NewSession(String protocolIdentifier, int settingsID)
        //{
        //    if (_protocols.ContainsKey(protocolIdentifier))
        //        return NewSession(_protocols[protocolIdentifier], settingsID);
        //    else
        //        throw new ExceptionSystem.ExceptionBase.Exceptions.ProtocolInvalidException(String.Format("Given protocol identifer is not valid (ident: {0})", protocolIdentifier));
        //}

        //public Session NewSession(Protocol protocol, int settingsID)
        //{
        //    return protocol.NewSession(this._server, settingsID);
        //}

        public Session NewSession(long connectionSettingID)
        {
            Logger.Log(LogEntryType.Info, String.Format("Initiating new session object called from host"), _loggerContext);
            Logger.Log(LogEntryType.Debug, String.Format("... session object for server: {0}", _server), _loggerContext);
            Logger.Log(LogEntryType.Debug, String.Format("... session object for db connection id: {0}", GetConnectionID()), _loggerContext);
            Logger.Log(LogEntryType.Debug, String.Format("... session object for protocol: {0}", GetProtocol(connectionSettingID).GetProtocolName()), _loggerContext);

            ConnectionProtocol db_protocol = StorageCore.Core.GetConnectionSetting(connectionSettingID);

            if (!Kernel.GetAvailableProtocols().ContainsKey(db_protocol.Protocol))
            {
                throw new ProtocolException(beRemoteExInfoPackage.SignificantInformationPackage, "Protocol with given identifier not found in Kernel (" + db_protocol.Protocol + "; db-id: " + db_protocol.Id.ToString() + ")");
            }

            Protocol protocol = Kernel.GetAvailableProtocols()[db_protocol.Protocol];


            Session sess = protocol.NewSession(this._server, connectionSettingID);

            //try
            //{
            //    if (sess.IsInDebugMode())
            //        Kernel.GetDebugWorker().AddDebugObject("Sessions", sess);
            //}
            //catch (Exception ex)
            //{
            //    // if this is thrown we don't have a valid debugger
            //}

            return(sess);
        }
Example #3
0
    public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol)
        : base(listener, connectionProtocol)
    {
        #if UNITY_EDITOR || (!UNITY_IPHONE && !UNITY_ANDROID && !UNITY_PS3)
        Debug.Log("Using C# Socket");
        this.SocketImplementation = typeof(SocketUdp);
        #elif !UNITY_EDITOR && UNITY_PS3
        Debug.Log("Using class SocketUdpNativeDllImport");
        this.SocketImplementation = typeof(SocketUdpNativeDllImport);
        #elif !UNITY_EDITOR && UNITY_ANDROID
        Debug.Log("Using class SocketUdpNativeDynamic");
        this.SocketImplementation = typeof(SocketUdpNativeDynamic);
        #elif !UNITY_EDITOR && UNITY_IPHONE
        Debug.Log("Using class SocketUdpNativeStatic");
        this.SocketImplementation = typeof(SocketUdpNativeStatic);
        #endif

        this.Listener = this;

        // don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
        this.externalListener = listener;
        this.PlayerName = playername;
        this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
        this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);

        // RPC shortcut lookup creation (from list of RPCs, which is updated by Editor scripts)
        rpcShortcuts = new Dictionary<string, int>(PhotonNetwork.PhotonServerSettings.RpcList.Count);
        for (int index = 0; index < PhotonNetwork.PhotonServerSettings.RpcList.Count; index++)
        {
            var name = PhotonNetwork.PhotonServerSettings.RpcList[index];
            rpcShortcuts[name] = index;
        }

        this.State = global::PeerState.PeerCreated;
    }
Example #4
0
        public static int GetDefaultPort(ConnectionProtocol protocol)
        {
            int port = 22;

            switch (protocol)
            {
            case ConnectionProtocol.Raw:
                break;

            case ConnectionProtocol.Rlogin:
                port = 513;
                break;

            case ConnectionProtocol.Serial:
                break;

            case ConnectionProtocol.Telnet:
                port = 23;
                break;

            case ConnectionProtocol.VNC:
                port = 0;
                break;
            }
            return(port);
        }
Example #5
0
        public ChatPeer(IPhotonPeerListener listener, ConnectionProtocol protocol) : base(listener, 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("Using class SocketUdpNativeDynamic");
                this.SocketImplementation = typeof(SocketUdpNativeDynamic);
#elif !UNITY_EDITOR && UNITY_IPHONE
                UnityEngine.Debug.Log("Using class SocketUdpNativeStatic");
                this.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.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.SocketImplementation == null)
                {
                    UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
                }
            }
#pragma warning restore 0162

            if (protocol == ConnectionProtocol.WebSocket || protocol == ConnectionProtocol.WebSocketSecure)
            {
                UnityEngine.Debug.Log("Using SocketWebTcp");
                this.SocketImplementation = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp");//typeof(SocketWebTcp);
            }
        }
        public static void Get_GamePeerIP_X(this ModelManager mmng)
        {
            ServerListModelData data       = mmng.GetData <ServerListModelData>(EModelType.Model_serverlist);
            List <ServerInfo>   serverlist = data.serverlist;
            int currLoginServerIndex       = data.currLoginServerIndex;

            if (serverlist == null)
            {
                return;
            }
            if (currLoginServerIndex >= 0 && currLoginServerIndex < serverlist.Count)
            {
                MobaPeer           mobaPeer     = NetWorkHelper.Instance.client.GetMobaPeer(MobaPeerType.C2GateServer, true);
                ConnectionProtocol usedProtocol = mobaPeer.UsedProtocol;
                if (usedProtocol != ConnectionProtocol.Udp)
                {
                    if (usedProtocol == ConnectionProtocol.Tcp)
                    {
                        data.mGamePeerServerName = serverlist[currLoginServerIndex].tcpaddress;
                    }
                }
                else
                {
                    data.mGamePeerServerName = serverlist[currLoginServerIndex].udpaddress;
                }
                data.mGamePeerAppName = serverlist[currLoginServerIndex].servername;
                data.ServerId         = serverlist[currLoginServerIndex].serverid;
            }
        }
Example #7
0
        public static Process Start(string serverAddress, string appId, ConnectionProtocol protocol,
                                    string photonCmdLine)
        {
            const string defaultRelativeWorkingDirectory = "\\..\\..\\..\\";

            return(Start(serverAddress, appId, protocol, photonCmdLine, defaultRelativeWorkingDirectory));
        }
Example #8
0
 protected void ReApplySettingsToWindow()
 {
     this.cloudAppId     = string.IsNullOrEmpty(PhotonEditor.Current.AppID) ? string.Empty : PhotonEditor.Current.AppID;
     this.photonAddress  = string.IsNullOrEmpty(PhotonEditor.Current.ServerAddress) ? string.Empty : PhotonEditor.Current.ServerAddress;
     this.photonPort     = PhotonEditor.Current.ServerPort;
     this.photonProtocol = PhotonEditor.Current.Protocol;
 }
Example #9
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 #10
0
        private static bool CheckConnection(string serverAddress, string appId, ConnectionProtocol protocol)
        {
            var listner = new PhotonListener(false);
            var peer    = new PhotonPeer(listner, protocol);

            if (!peer.Connect(serverAddress, appId))
            {
                return(false);
            }

            var counter = 100;

            while (--counter > 0)
            {
                peer.Service();
                if (listner.WaitForConnection(0))
                {
                    var res = peer.PeerState == PeerStateValue.Connected;
                    peer.Disconnect();
                    return(res);
                }
                Thread.Sleep(50);
            }
            return(false);
        }
Example #11
0
        public ChatPeer(IPhotonPeerListener listener, ConnectionProtocol protocol) : base(listener, 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.SocketImplementation = typeof(SocketUdpNativeDynamic);
#elif !UNITY_EDITOR && UNITY_IPHONE
                UnityEngine.Debug.Log("Using class SocketUdpNativeStatic");
                this.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.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.SocketImplementation == null)
                {
                    UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
                }
            }
#pragma warning restore 0162
			if (protocol == ConnectionProtocol.WebSocket || protocol == ConnectionProtocol.WebSocketSecure) {
            	UnityEngine.Debug.Log("Using SocketWebTcp");
            	this.SocketImplementation = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp");//typeof(SocketWebTcp);
			}
#endif
        }
Example #12
0
        /// <summary>
        /// Gets the NameServer Address (with prefix and port), based on the set protocol (this.UsedProtocol).
        /// </summary>
        /// <returns>NameServer Address (with prefix and port).</returns>
        private string GetNameServerAddress()
        {
                        #if RHTTP
            if (currentProtocol == ConnectionProtocol.RHttp)
            {
                return(NameServerHttp);
            }
                        #endif

            ConnectionProtocol currentProtocol = this.UsedProtocol;
            int protocolPort = 0;
            ProtocolToNameServerPort.TryGetValue(currentProtocol, out protocolPort);

            string protocolPrefix = string.Empty;
            if (currentProtocol == ConnectionProtocol.WebSocket)
            {
                protocolPrefix = "ws://";
            }
            else if (currentProtocol == ConnectionProtocol.WebSocketSecure)
            {
                protocolPrefix = "wss://";
            }

            return(string.Format("{0}{1}:{2}", protocolPrefix, NameServerHost, protocolPort));
        }
        public PhotonSocketConnection(ConnectionProtocol connectionProtocol, UpdateDispatcher updateDispatcher)
        {
            photonPeer = new PhotonPeer(this, connectionProtocol);

            this.updateDispatcher          = updateDispatcher;
            this.updateDispatcher.Updated += onUpdated;
        }
Example #14
0
 public SessionData(string sessionName, string hostName, int port, ConnectionProtocol protocol, string sessionConfig)
 {
     SessionName = sessionName;
     Host = hostName;
     Port = port;
     Proto = protocol;
     PuttySession = sessionConfig;
 }
Example #15
0
 /// <summary>
 /// Gets the name of the specified connection protocol.
 /// </summary>
 /// <param name="protocol">
 /// The protocol to get the name of.
 /// </param>
 /// <returns>
 /// The name of the specified protocol.
 /// </returns>
 public static String GetConnectionProtocolName(ConnectionProtocol protocol)
 {
     if (protocol == ConnectionProtocol.None)
     {
         return(String.Empty);
     }
     return(Enum.GetName(typeof(ConnectionProtocol), protocol));
 }
Example #16
0
 public SessionData(string sessionName, string hostName, int port, ConnectionProtocol protocol, string sessionConfig)
 {
     SessionName  = sessionName;
     Host         = hostName;
     Port         = port;
     Proto        = protocol;
     PuttySession = sessionConfig;
 }
 internal Connection(ConnectionProtocol protocol, IPEndPoint local, IPEndPoint remote, ConnectionState state, Process sourceProcess)
 {
     this.State         = state;
     this.SourceProcess = sourceProcess;
     this.Remote        = remote;
     this.Protocol      = protocol;
     this.Local         = local;
 }
Example #18
0
 private static ConnectPolicy GetPolicy(string policyName, ConnectionProtocol protocol)
 {
     switch (policyName)
     {
     case "LOCAL":
     default:
         return(new OnlineConnectPolicy(new TokenAuthenticationScheme(), protocol));
     }
 }
Example #19
0
    internal UnityVoiceFrontend(ConnectionProtocol connetProtocol) : base(connetProtocol)
    {
        this.voiceClient.OnRemoteVoiceInfoAction += OnRemoteVoiceInfo;
        this.AutoJoinLobby        = false;
        base.OnStateChangeAction += OnStateChange;
        base.OnOpResponseAction  += OnOpResponse;

        this.loadBalancingPeer.DebugOut = DebugLevel.INFO;
    }
Example #20
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "TestClient" /> class.
 /// </summary>
 public TestClient(ConnectionProtocol connectionProtocol)
 {
     this.autoResetEventInit = new AutoResetEvent(false);
     this.OperationResponseQueue = new Queue<OperationResponse>(1000); 
     this.EventQueue = new Queue<EventData>(1000);
    
     this.PhotonClient = new LoadBalancingPeer(this, connectionProtocol) { DebugOut = DebugLevel.INFO };
     this.fiber.Start();
 }
Example #21
0
        public bool Connect(string address, ConnectionProtocol protocol)
        {
            if (this.UsedProtocol != protocol)
            {
                return false;
            }

            return true;
        }
Example #22
0
 public MobaPeer(ConnectionProtocol protocolType, PhotonClient client, MobaPeerType peerType) : base(protocolType)
 {
     this.mClient         = client;
     this.mPeerType       = peerType;
     this.mEventHandles   = new Dictionary <byte, INetEventHandleBase>();
     this.mConnectedTimes = 0;
     this.mIsReconnect    = false;
     this.ServerConnected = false;
 }
Example #23
0
        public bool Connect(string address, ConnectionProtocol protocol)
        {
            if (this.UsedProtocol != protocol)
            {
                return(false);
            }

            return(true);
        }
Example #24
0
 public PhotonPeer(IPhotonPeerListener listener, ConnectionProtocol protocolType)
     : this(protocolType)
 {
     if (listener == null)
     {
         throw new Exception("listener cannot be null");
     }
     this.Listener = listener;
 }
Example #25
0
 public ChatClient(IChatClientListener listener, ConnectionProtocol protocol = 0)
 {
     this.listener                    = listener;
     this.State                       = ChatState.Uninitialized;
     this.chatPeer                    = new ChatPeer(this, protocol);
     this.PublicChannels              = new Dictionary <string, ChatChannel>();
     this.PrivateChannels             = new Dictionary <string, ChatChannel>();
     this.PublicChannelsUnsubscribing = new HashSet <string>();
 }
Example #26
0
 public LoadbalancingOnlineTests(string schemeName, AuthPolicy authPolicy, ConnectionProtocol protocol)
     : base(new OnlineConnectPolicy(GetAuthScheme(schemeName), protocol), AuthPolicy.AuthOnNameServer)
 {
     if (schemeName == "TokenAuthNoUserIds")
     {
         this.Player1 = null;
         this.Player2 = null;
         this.Player3 = null;
     }
 }
 internal Connection(ConnectionProtocol protocol, IPAddress localAdress, int localPort, IPAddress remoteAdress, int remotePort, ConnectionState state, Process sourceProcess)
     : this(
         protocol,
         new IPEndPoint(localAdress, localPort),
         new IPEndPoint(remoteAdress, remotePort),
         state,
         sourceProcess
         )
 {
 }
 public LoadbalancingOnlineTests(string schemeName, ConnectionProtocol protocol)
     : base(new OnlineConnectPolicy(GetAuthScheme(schemeName), protocol))
 {
     if (schemeName == "TokenLessAuthForOldClients" || schemeName == "TokenAuthNoUserIds")
     {
         this.Player1 = null;
         this.Player2 = null;
         this.Player3 = null;
     }
 }
 public LoadbalancingOnlineTests(string schemeName, ConnectionProtocol protocol)
     : base(new OnlineConnectPolicy(GetAuthScheme(schemeName), protocol))
 {
     if (schemeName == "TokenLessAuthForOldClients" || schemeName == "TokenAuthNoUserIds")
     {
         this.Player1 = null;
         this.Player2 = null;
         this.Player3 = null;
     }
 }
Example #30
0
    // Token: 0x06000053 RID: 83 RVA: 0x00003290 File Offset: 0x00001490
    internal UnityVoiceFrontend(ConnectionProtocol connetProtocol) : base(connetProtocol)
    {
        VoiceClient voiceClient = this.voiceClient;

        voiceClient.OnRemoteVoiceInfoAction = (VoiceClient.RemoteVoiceInfoDelegate)Delegate.Combine(voiceClient.OnRemoteVoiceInfoAction, new VoiceClient.RemoteVoiceInfoDelegate(this.OnRemoteVoiceInfo));
        base.AutoJoinLobby              = false;
        base.OnStateChangeAction        = (Action <ExitGames.Client.Photon.LoadBalancing.ClientState>)Delegate.Combine(base.OnStateChangeAction, new Action <ExitGames.Client.Photon.LoadBalancing.ClientState>(this.OnStateChange));
        base.OnOpResponseAction        += this.OnOpResponse;
        this.loadBalancingPeer.DebugOut = DebugLevel.INFO;
    }
    public void ConnectToChatServer()
    {
        ConnectionProtocol connectionProtocol = ConnectionProtocol.Udp;

        this.client = new ChatClient(this, connectionProtocol);
        AuthenticationValues authenticationValues = new AuthenticationValues();

        authenticationValues.AuthType = CustomAuthenticationType.None;
        this.client.Connect(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat, "0", authenticationValues);
        this.connectionState.text = "Connecting to chat server...";
        Debug.Log("Attempting to Connect to Chat.");
    }
Example #32
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "TestClient" /> class.
        /// </summary>
        /// <param name = "useTcp">
        ///   The use Tcp.
        /// </param>
        public TestClient(ConnectionProtocol connectionProtocol)
        {
            this.autoResetEventInit     = new AutoResetEvent(false);
            this.OperationResponseQueue = new Queue <OperationResponse>(1000);
            this.EventQueue             = new Queue <EventData>(1000);

            this.PhotonClient = new LoadBalancingPeer(this, connectionProtocol)
            {
                DebugOut = DebugLevel.INFO
            };
            this.fiber.Start();
        }
        /// <summary>
        ///   Initializes a new instance of the <see cref = "OnlineNUnitClient" /> class.
        /// </summary>
        public OnlineNUnitClient(ConnectionProtocol connectionProtocol, bool logPhotonClientMessages = false)
        {
            this.Id = Interlocked.Increment(ref curentId);
            this.LogPhotonClientMessages = logPhotonClientMessages;

            this.autoResetEventInit = new AutoResetEvent(false);
            this.OperationResponseQueue = new Queue<OperationResponse>(1000);
            this.EventQueue = new Queue<EventData>(1000);

            this.Peer = new PhotonPeer(this, connectionProtocol) { DebugOut = DebugLevel.INFO };
            this.fiber.Start();
        }
        }                                                                              // called by voice client action, so user still can use action

        /// <summary>Creates Client instance</summary>
        public LoadBalancingFrontend(ConnectionProtocol connectionProtocol = ConnectionProtocol.Udp) : base(connectionProtocol)
        {
            base.OnEventAction       += onEventActionVoiceClient;
            base.OnStateChangeAction += onStateChangeVoiceClient;
            this.voiceClient          = new VoiceClient(this);
            var voiceChannelsCount = Enum.GetValues(typeof(Codec)).Length + 1; // channel per stream type, channel 0 is for user events

            if (loadBalancingPeer.ChannelCount < voiceChannelsCount)
            {
                this.loadBalancingPeer.ChannelCount = (byte)voiceChannelsCount;
            }
        }
Example #35
0
        /// <summary>
        /// Initializes a new <see cref="LoadBalancingTransport"/>.
        /// </summary>
        /// <param name="connectionProtocol">Connection protocol (UDP or TCP). <see cref="ConnectionProtocol"></see></param>
        public LoadBalancingTransport(ConnectionProtocol connectionProtocol = ConnectionProtocol.Udp) : base(connectionProtocol)
        {
            base.EventReceived += onEventActionVoiceClient;
            base.StateChanged  += onStateChangeVoiceClient;
            this.voiceClient    = new VoiceClient(this);
            var voiceChannelsCount = Enum.GetValues(typeof(Codec)).Length + 1; // channel per stream type, channel 0 is for user events

            if (LoadBalancingPeer.ChannelCount < voiceChannelsCount)
            {
                this.LoadBalancingPeer.ChannelCount = (byte)voiceChannelsCount;
            }
            this.protocol = new PhotonTransportProtocol(voiceClient, this);
        }
 public static ConnectPolicy GetPolicy(string policyName, ConnectionProtocol protocol)
 {
     switch (policyName)
     {
         case "DEV":
             //    return new OnlineConnectPolicy(new TokenAuthenticationScheme(), protocol)
         case "LIVE":
             //    return new OnlineConnectPolicy(new TokenAuthenticationScheme(), protocol);
         case "LOCAL":
         default:
             return new OnlineConnectPolicy(new TokenAuthenticationScheme(), protocol);
     }
 }
Example #37
0
 public static void SwitchToProtocol(ConnectionProtocol cp)
 {
     if (networkingPeer.UsedProtocol != cp)
     {
         try {
             networkingPeer.Disconnect();
             networkingPeer.StopThread();
         } catch {
         }
         networkingPeer = new NetworkingPeer(photonMono, string.Empty, cp);
         Debug.Log("Protocol switched to: " + cp);
     }
 }
Example #38
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "TestClient" /> class.
        /// </summary>
        /// <param name = "useTcp">
        ///   The use Tcp.
        /// </param>
        public TestClient(bool useTcp)
        {
            ConnectionProtocol protocol = useTcp ? ConnectionProtocol.Tcp : ConnectionProtocol.Udp;

            this.autoResetEventInit     = new AutoResetEvent(false);
            this.operationResponseQueue = new BlockingQueue <OperationResponse>(1000, 1000);
            this.eventQueue             = new BlockingQueue <EventData>(1000, 1000);

            this.PhotonClient = new PhotonPeer(this, protocol)
            {
                DebugOut = DebugLevel.INFO
            };
            this.fiber.Start();
        }
Example #39
0
        public static Process Start(string serverAddress, string appId, ConnectionProtocol protocol, string photonCmdLine, string relativeWorkingDirectory)
        {
            if (CheckConnection(serverAddress, appId, protocol))
            {
                return null;
            }

            if (!IsLocalAddress(serverAddress))
            {
                throw new Exception(string.Format((string) "failed to establish connection to {0} using protocol {1}", serverAddress, protocol));
            }

            var path = FindPhoton();
            Environment.CurrentDirectory += relativeWorkingDirectory;

            return StartPhoton(serverAddress, appId, protocol, path, photonCmdLine);
        }
Example #40
0
    public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol)
        : base(listener, connectionProtocol)
    {
        this.Listener = this;

        // don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
        this.externalListener = listener;
        this.PlayerName = playername;
        this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
        this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);

        // RPC shortcut lookup creation (from list of RPCs, which is updated by Editor scripts)
        rpcShortcuts = new Dictionary<string, int>(PhotonNetwork.PhotonServerSettings.RpcList.Count);
        for (int index = 0; index < PhotonNetwork.PhotonServerSettings.RpcList.Count; index++)
        {
            var name = PhotonNetwork.PhotonServerSettings.RpcList[index];
            rpcShortcuts[name] = index;
        }

        this.State = global::PeerState.PeerCreated;
    }
Example #41
0
        private static bool CheckConnection(string serverAddress, string appId, ConnectionProtocol protocol)
        {
            var listner = new PhotonListener(false);
            var peer = new PhotonPeer(listner, protocol);

            if (!peer.Connect(serverAddress, appId))
            {
                return false;
            }

            var counter = 100;
            while (--counter > 0)
            {
                peer.Service();
                if (listner.WaitForConnection(0))
                {
                    var res = peer.PeerState == PeerStateValue.Connected;
                    peer.Disconnect();
                    return res;
                }
                Thread.Sleep(50);
            }
            return false;
        }
Example #42
0
 public static int GetDefaultPort(ConnectionProtocol protocol)
 {
     int port = 22;
     switch (protocol)
     {
         case ConnectionProtocol.Raw:
             break;
         case ConnectionProtocol.Rlogin:
             port = 513;
             break;
         case ConnectionProtocol.Serial:
             break;
         case ConnectionProtocol.Telnet:
             port = 23;
             break;
     }
     return port;
 }
Example #43
0
    /// <summary>
    /// While offline, the network protocol can be switched (which affects the ports you can use to connect).
    /// </summary>
    /// <remarks>
    /// When you switch the protocol, make sure to also switch the port for the master server. Default ports are:
    /// TCP: 4530
    /// UDP: 5055
    ///
    /// This could look like this:<br/>
    /// Connect(serverAddress, <udpport|tcpport>, appID, gameVersion)
    ///
    /// Or when you use ConnectUsingSettings(), the PORT in the settings can be switched like so:<br/>
    /// PhotonNetwork.PhotonServerSettings.ServerPort = 4530;
    ///
    /// The current protocol can be read this way:<br/>
    /// PhotonNetwork.networkingPeer.UsedProtocol
    ///
    /// This does not work with the native socket plugin of PUN+ on mobile!
    /// </remarks>
    /// <param name="cp">Network protocol to use as low level connection. UDP is default. TCP is not available on all platforms (see remarks).</param>
    public static void SwitchToProtocol(ConnectionProtocol cp)
    {
        #if UNITY_WEBGL
        if (cp != ConnectionProtocol.WebSocket && cp != ConnectionProtocol.WebSocketSecure) {
            Debug.Log("WebGL only supports WebSocket protocol. Overriding PhotonServerSettings.");
            cp = ConnectionProtocol.WebSocketSecure;
        }
        #endif

        if (networkingPeer.UsedProtocol == cp)
        {
            return;
        }
        try
        {
            networkingPeer.Disconnect();
            networkingPeer.StopThread();
        }
        catch
        {

        }

        // set up a new NetworkingPeer
        NetworkingPeer newPeer = new NetworkingPeer(photonMono, String.Empty, cp);
        newPeer.mAppVersion = networkingPeer.mAppVersion;
        newPeer.CustomAuthenticationValues = networkingPeer.CustomAuthenticationValues;
        newPeer.PlayerName= networkingPeer.PlayerName;
        newPeer.mLocalActor = networkingPeer.mLocalActor;
        newPeer.DebugOut = networkingPeer.DebugOut;
        newPeer.CrcEnabled = networkingPeer.CrcEnabled;
        newPeer.QuickResendAttempts = networkingPeer.QuickResendAttempts;
        newPeer.lobby = networkingPeer.lobby;
        newPeer.LimitOfUnreliableCommands = networkingPeer.LimitOfUnreliableCommands;
        newPeer.SentCountAllowance = networkingPeer.SentCountAllowance;
        newPeer.TrafficStatsEnabled = networkingPeer.TrafficStatsEnabled;

        networkingPeer = newPeer;
        Debug.LogWarning("Protocol switched to: " + cp + ".");
    }
    protected virtual void OnGuiSetupSelfhosting()
    {
        GUILayout.Label(CurrentLang.YourPhotonServerLabel);

        this.photonAddress = EditorGUILayout.TextField(CurrentLang.AddressIPLabel, this.photonAddress);
        this.photonPort = EditorGUILayout.IntField(CurrentLang.PortLabel, this.photonPort);
        this.photonProtocol = (ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol", this.photonProtocol);
        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button(CurrentLang.CancelButton))
        {
            GUIUtility.keyboardControl = 0;
            this.ReApplySettingsToWindow();
        }

        if (GUILayout.Button(CurrentLang.SaveButton))
        {
            GUIUtility.keyboardControl = 0;

            PhotonEditor.Current.UseMyServer(this.photonAddress, this.photonPort, null);
            PhotonEditor.Current.Protocol = this.photonProtocol;
            PhotonEditor.Save();

            Inspect();
            EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton);
        }

        GUILayout.EndHorizontal();


        GUILayout.Space(20);


        // license
        GUILayout.BeginHorizontal();
        GUILayout.Label(CurrentLang.LicensesLabel, EditorStyles.boldLabel, GUILayout.Width(100));

        if (GUILayout.Button(new GUIContent(CurrentLang.LicenseDownloadText, CurrentLang.LicenseDownloadTooltip)))
        {
            EditorUtility.OpenWithDefaultApp(UrlFreeLicense);
        }

        GUILayout.EndHorizontal();


        GUILayout.Space(20);


        GUILayout.Label(CurrentLang.TryPhotonAppLabel);

        if (GUILayout.Button(CurrentLang.GetCloudAppButton))
        {
            this.cloudAppId = string.Empty;
            this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
        }

        EditorGUILayout.Separator();
        GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel);
        if (GUILayout.Button(CurrentLang.ComparisonPageButton))
        {
            Application.OpenURL(UrlCompare);
        }
    }
 protected void ReApplySettingsToWindow()
 {
     this.cloudAppId = string.IsNullOrEmpty(PhotonEditor.Current.AppID) ? string.Empty : PhotonEditor.Current.AppID;
     this.photonAddress = string.IsNullOrEmpty(PhotonEditor.Current.ServerAddress) ? string.Empty : PhotonEditor.Current.ServerAddress;
     this.photonPort = PhotonEditor.Current.ServerPort;
     this.photonProtocol = PhotonEditor.Current.Protocol;
 }
Example #46
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;
        }
    /// <summary>
    /// While offline, the network protocol can be switched from UDP to TCP at will but make sure to use the fitting port, too.
    /// </summary>
    /// <remarks>
    /// When you switch the protocol, make sure to also switch the port for the master server. Default ports are:
    /// TCP: 4530
    /// UDP: 5055
    ///
    /// This could look like this:
    /// Connect(serverAddress, <udpport|tcpport>, appID, gameVersion)
    ///
    /// Or when you use ConnectUsingSettings(), the PORT in the settings can be switched like so:
    /// PhotonNetwork.PhotonServerSettings.ServerPort = 4530;
    ///
    /// The current protocol can be read this way:
    /// PhotonNetwork.networkingPeer.UsedProtocol
    ///
    /// This does not work with the native socket plugin of PUN+ on mobile!
    /// </remarks>
    /// <param name="cp">Network protocol to use as low level connection. UDP is default. TCP is not available on all platforms (see remarks).</param>
    public static void SwitchToProtocol(ConnectionProtocol cp)
    {
        if (networkingPeer.UsedProtocol == cp)
        {
            return;
        }
        try
        {
            networkingPeer.Disconnect();
            networkingPeer.StopThread();
        }
        catch
        {

        }

        // Set up the NetworkingPeer
        networkingPeer = new NetworkingPeer(photonMono, String.Empty, cp);

        Debug.Log("Protocol switched to: " + cp);
    }
Example #48
0
 public LoadbalancingPeer(IPhotonPeerListener listener, ConnectionProtocol protocolType)
     : base(listener, protocolType)
 {
 }
Example #49
0
 public static Process Start(string serverAddress, string appId, ConnectionProtocol protocol,
     string photonCmdLine)
 {
     const string defaultRelativeWorkingDirectory = "\\..\\..\\..\\";
     return Start(serverAddress, appId, protocol, photonCmdLine, defaultRelativeWorkingDirectory);
 }
Example #50
0
 /// <summary>
 /// While offline, the network protocol can be switched (which affects the ports you can use to connect).
 /// </summary>
 /// <remarks>
 /// When you switch the protocol, make sure to also switch the port for the master server. Default ports are:
 /// TCP: 4530
 /// UDP: 5055
 ///
 /// This could look like this:<br/>
 /// Connect(serverAddress, <udpport|tcpport>, appID, gameVersion)
 ///
 /// Or when you use ConnectUsingSettings(), the PORT in the settings can be switched like so:<br/>
 /// PhotonNetwork.PhotonServerSettings.ServerPort = 4530;
 ///
 /// The current protocol can be read this way:<br/>
 /// PhotonNetwork.networkingPeer.UsedProtocol
 ///
 /// This does not work with the native socket plugin of PUN+ on mobile!
 /// </remarks>
 /// <param name="cp">Network protocol to use as low level connection. UDP is default. TCP is not available on all platforms (see remarks).</param>
 public static void SwitchToProtocol(ConnectionProtocol cp)
 {
     Debug.Log("SwitchToProtocol: " + cp + " PhotonNetwork.connected: " + PhotonNetwork.connected);
     networkingPeer.TransportProtocol = cp;
 }
Example #51
0
        public ChatClient(IChatClientListener listener, ConnectionProtocol protocol =
#if UNITY_WEBGL
    ConnectionProtocol.WebSocketSecure
#else
    ConnectionProtocol.Udp
#endif
        )
        {
#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

            this.listener = listener;
            this.State = ChatState.Uninitialized;

            this.chatPeer = new ChatPeer(this, protocol);

            this.PublicChannels = new Dictionary<string, ChatChannel>();
            this.PrivateChannels = new Dictionary<string, ChatChannel>();
        }
Example #52
0
 /// <summary>
 /// Creates a LitePeer instance to connect and communicate with a Photon server.
 /// </summary>
 protected LitePeer(ConnectionProtocol protocolType) : base(protocolType)
 {
 }
Example #53
0
    private readonly Dictionary<byte, object> opParameters = new Dictionary<byte, object>(); // used in OpRaiseEvent() (avoids lots of new Dictionary() calls)

    #endregion Fields

    #region Constructors

    /// <summary>
    /// Creates a Peer with selected connection protocol.
    /// </summary>
    /// <remarks>Each connection protocol has it's own default networking ports for Photon.</remarks>
    /// <param name="protocolType">The preferred option is UDP.</param>
    public LoadBalancingPeer(ConnectionProtocol protocolType)
        : base(protocolType)
    {
        // this does not require a Listener, so:
            // make sure to set this.Listener before using a peer!
    }
Example #54
0
    /// <summary>
    /// While offline, the network protocol can be switched (which affects the ports you can use to connect).
    /// </summary>
    /// <remarks>
    /// When you switch the protocol, make sure to also switch the port for the master server. Default ports are:
    /// TCP: 4530
    /// UDP: 5055
    ///
    /// This could look like this:<br/>
    /// Connect(serverAddress, <udpport|tcpport>, appID, gameVersion)
    ///
    /// Or when you use ConnectUsingSettings(), the PORT in the settings can be switched like so:<br/>
    /// PhotonNetwork.PhotonServerSettings.ServerPort = 4530;
    ///
    /// The current protocol can be read this way:<br/>
    /// PhotonNetwork.networkingPeer.UsedProtocol
    ///
    /// This does not work with the native socket plugin of PUN+ on mobile!
    /// </remarks>
    /// <param name="cp">Network protocol to use as low level connection. UDP is default. TCP is not available on all platforms (see remarks).</param>
    public static void SwitchToProtocol(ConnectionProtocol cp)
    {
        if (networkingPeer.UsedProtocol == cp)
        {
            return;
        }
        try
        {
            networkingPeer.Disconnect();
            networkingPeer.StopThread();
        }
        catch
        {

        }

        // set up a new NetworkingPeer
        NetworkingPeer newPeer = new NetworkingPeer(photonMono, String.Empty, cp);
        newPeer.mAppVersion = networkingPeer.mAppVersion;
        newPeer.CustomAuthenticationValues = networkingPeer.CustomAuthenticationValues;
        newPeer.PlayerName= networkingPeer.PlayerName;
        newPeer.mLocalActor = networkingPeer.mLocalActor;
        newPeer.DebugOut = networkingPeer.DebugOut;
        newPeer.CrcEnabled = networkingPeer.CrcEnabled;
        newPeer.lobby = networkingPeer.lobby;
        newPeer.LimitOfUnreliableCommands = networkingPeer.LimitOfUnreliableCommands;
        newPeer.SentCountAllowance = networkingPeer.SentCountAllowance;
        newPeer.TrafficStatsEnabled = networkingPeer.TrafficStatsEnabled;

        networkingPeer = newPeer;
        Debug.LogWarning("Protocol switched to: " + cp + ".");
    }
Example #55
0
 /// <summary>
 /// Creates a LitePeer instance to communicate with Photon with your selection of protocol.
 /// We recommend UDP.
 /// </summary>
 /// <param name="listener">Your IPhotonPeerListener implementation.</param>
 /// <param name="protocolType">Protocol to use to connect to Photon.</param>
 public LitePeer(IPhotonPeerListener listener, ConnectionProtocol protocolType) : base(listener, protocolType)
 {
 }
Example #56
0
    /// <summary>
    /// Sends this app's appId and appVersion to identify this application server side.
    /// This is an async request which triggers a OnOperationResponse() call.
    /// </summary>
    /// <remarks>
    /// This operation makes use of encryption, if that is established before.
    /// See: EstablishEncryption(). Check encryption with IsEncryptionAvailable.
    /// This operation is allowed only once per connection (multiple calls will have ErrorCode != Ok).
    /// </remarks>
    /// <param name="appId">Your application's name or ID to authenticate. This is assigned by Photon Cloud (webpage).</param>
    /// <param name="appVersion">The client's version (clients with differing client appVersions are separated and players don't meet).</param>
    /// <param name="authValues">Optional authentication values. The client can set no values or a UserId or some parameters for Custom Authentication by a server.</param>
    /// <param name="regionCode">Optional region code, if the client should connect to a specific Photon Cloud Region.</param>
    /// <param name="encryptionMode"></param>
    /// <param name="expectedProtocol"></param>
    /// <returns>If the operation could be sent (has to be connected).</returns>
    public virtual bool OpAuthenticateOnce(string appId, string appVersion, AuthenticationValues authValues, string regionCode, EncryptionMode encryptionMode, ConnectionProtocol expectedProtocol)
    {
        if (this.DebugOut >= DebugLevel.INFO)
            {
                this.Listener.DebugReturn(DebugLevel.INFO, "OpAuthenticate()");
            }

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

            // shortcut, if we have a Token
            if (authValues != null && authValues.Token != null)
            {
                opParameters[ParameterCode.Secret] = authValues.Token;
                return this.OpCustom(OperationCode.AuthenticateOnce, opParameters, true, (byte)0, false);   // we don't have to encrypt, when we have a token (which is encrypted)
            }

            if (encryptionMode == EncryptionMode.DatagramEncryption && expectedProtocol != ConnectionProtocol.Udp)
            {
                Debug.LogWarning("Expected protocol set to UDP, due to encryption mode DatagramEncryption. Changing protocol in PhotonServerSettings from: " + PhotonNetwork.PhotonServerSettings.Protocol);
                PhotonNetwork.PhotonServerSettings.Protocol = ConnectionProtocol.Udp;
                expectedProtocol = ConnectionProtocol.Udp;
            }

            opParameters[ParameterCode.ExpectedProtocol] = (byte)expectedProtocol;
            opParameters[ParameterCode.EncryptionMode] = (byte)encryptionMode;

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

            if (!string.IsNullOrEmpty(regionCode))
            {
                opParameters[ParameterCode.Region] = regionCode;
            }

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

                if (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;
                        }
                    }
                }
            }

            return this.OpCustom(OperationCode.AuthenticateOnce, opParameters, true, (byte)0, this.IsEncryptionAvailable);
    }
    public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol) : base(listener, connectionProtocol)
    {
        #if !UNITY_EDITOR && (UNITY_WINRT)
        // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
        Debug.LogWarning("Using PingWindowsStore");
        PhotonHandler.PingImplementation = typeof(PingWindowsStore);    // but for ping, we have to set the implementation explicitly to Win 8 Store/Phone
        #endif

        #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)
            Debug.Log("Using class SocketUdpNativeDynamic");
            this.SocketImplementation = typeof(SocketUdpNativeDynamic);
            PhotonHandler.PingImplementation = typeof(PingNativeDynamic);
            #elif !UNITY_EDITOR && UNITY_IPHONE
            Debug.Log("Using class SocketUdpNativeStatic");
            this.SocketImplementation = typeof(SocketUdpNativeStatic);
            PhotonHandler.PingImplementation = typeof(PingNativeStatic);
            #elif !UNITY_EDITOR && (UNITY_WINRT)
            // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
            #else
            this.SocketImplementation = typeof (SocketUdp);
            PhotonHandler.PingImplementation = typeof(PingMonoEditor);
            #endif

            if (this.SocketImplementation == null)
            {
                Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
            }
        }
        #pragma warning restore 0162

        if (PhotonHandler.PingImplementation == null)
        {
            PhotonHandler.PingImplementation = typeof(PingMono);
        }

        this.Listener = this;
        this.lobby = TypedLobby.Default;
        this.LimitOfUnreliableCommands = 40;

        // don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
        this.externalListener = listener;
        this.PlayerName = playername;
        this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
        this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);

        // RPC shortcut lookup creation (from list of RPCs, which is updated by Editor scripts)
        rpcShortcuts = new Dictionary<string, int>(PhotonNetwork.PhotonServerSettings.RpcList.Count);
        for (int index = 0; index < PhotonNetwork.PhotonServerSettings.RpcList.Count; index++)
        {
            var name = PhotonNetwork.PhotonServerSettings.RpcList[index];
            rpcShortcuts[name] = index;
        }

        this.State = global::PeerState.PeerCreated;
    }
Example #58
0
        private static Process StartPhoton(string serverAddress, string appId, ConnectionProtocol protocol, string path, string photonCmdLine)
        {
            var process = Process.Start(path, photonCmdLine);
            if (process == null)
            {
                throw new Exception("PhotonSocketServer.exe can not be started");
            }

            if (process.WaitForExit(6500))
            {
                throw new Exception(string.Format("'{0}' finished unexpectedly.", path));
            }

            // we try to connect to new process
            var count = 15;
            while (count-- > 0)
            {
                if (CheckConnection(serverAddress, appId, protocol))
                {
                    return process;
                }

                if (process.WaitForExit(1000))
                {
                    process.Close();
                    throw new Exception(string.Format("'{0}' finished unexpectedly", path));
                }
            }

            process.CloseMainWindow();
            if (!process.WaitForExit(1000))
            {
                process.Kill();
            }
            process.Close();
            throw new Exception(string.Format("Unable to connect to address={1} and process {0}", path, serverAddress));
        }
Example #59
0
        private readonly Dictionary<byte, object> opParameters = new Dictionary<byte, object>(); // used in OpRaiseEvent() (avoids lots of new Dictionary() calls)

        #endregion Fields

        #region Constructors

        public LoadbalancingPeer(ConnectionProtocol protocolType)
            : base(protocolType)
        {
        }
    public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol)
        : base(listener, connectionProtocol)
    {
        this.Listener = this;

        // don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
        this.externalListener = listener;
        this.PlayerName = playername;
        this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
        this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);

        this.State = global::PeerState.PeerCreated;
    }