예제 #1
0
        protected ServerConnectionInformation GetServerConnectionInformation(ServerType serverType)
        {
            var connectionInformation     = ServicesConfiguration.GetInstance().GetConnectionInformation(serverType);
            var peerConnectionInformation = NetworkConfiguration.GetInstance().GetPeerConnectionInformation(connectionInformation);

            return(new ServerConnectionInformation(serverType, peerConnectionInformation));
        }
        public async Task <ConnectionStatus> Connect(IYield yield, ICoroutinesExecutor coroutinesExecutor, ServerConnectionInformation serverConnectionInformation)
        {
            var serverType = serverConnectionInformation.ServerType;

            if (IsConnected())
            {
                throw new ServerConnectionFailed($"A connection already exists with a {serverType} server.");
            }

            ConnectionInformation = serverConnectionInformation;

            var ip   = ConnectionInformation.PeerConnectionInformation.Ip;
            var port = ConnectionInformation.PeerConnectionInformation.Port;

            LogUtils.Log($"Connecting to a {serverType} server. IP: {ip} Port: {port}");

            var serverConnector      = new PhotonServerConnector(() => coroutinesExecutor);
            var networkConfiguration = NetworkConfiguration.GetInstance();
            var connectionDetails    = new ConnectionDetails(networkConfiguration.ConnectionProtocol, networkConfiguration.DebugLevel);

            ServerPeer = await serverConnector.ConnectAsync(yield, ConnectionInformation.PeerConnectionInformation, connectionDetails);

            if (ServerPeer == null)
            {
                return(ConnectionStatus.Failed);
            }

            SubscribeToDisconnectionNotifier();

            LogUtils.Log($"A {serverType} server has been connected: {ip}:{port}");

            serviceConnectionNotifier.Connection();
            return(ConnectionStatus.Succeed);
        }
예제 #3
0
        public void Initialize(IServerPeer peer)
        {
            serverPeer = peer;

            var networkConfiguration = NetworkConfiguration.GetInstance();

            operationRequestSender = new OperationRequestSender <TOperationCode>(serverPeer.OperationRequestSender, networkConfiguration.LogOperationsRequest);
            subscriptionProvider   = new OperationResponseSubscriptionProvider <TOperationCode>(serverPeer.OperationResponseNotifier, OnOperationRequestFailed,
                                                                                                networkConfiguration.LogOperationsResponse);
            eventHandlerRegister = new EventHandlerRegister <TEventCode>(serverPeer.EventNotifier, networkConfiguration.LogEvents);
        }
예제 #4
0
        private void Awake()
        {
            var networkConfiguration = NetworkConfiguration.GetInstance();

            if (networkConfiguration != null)
            {
                var serverData =
                    networkConfiguration.GetServerData(ServerType.Authenticator);

                url = serverData.Url;
            }
        }
예제 #5
0
        private void Start()
        {
            var networkConfiguration = NetworkConfiguration.GetInstance();

            if (networkConfiguration != null)
            {
                if (networkConfiguration.IsDevelopment())
                {
                    StartCoroutine(WaitFrameAndStart());
                }
            }
        }
예제 #6
0
        public static ICharacterProviderApi ProvideCharacterProviderApi()
        {
            if (characterProviderApi == null)
            {
                var networkConfiguration = NetworkConfiguration.GetInstance();
                if (networkConfiguration.IsProduction())
                {
                    characterProviderApi = HttpCharacterProviderApi.GetInstance();
                }
                else
                {
                    characterProviderApi = DummyCharacterProviderApi.GetInstance();
                }
            }

            return(characterProviderApi);
        }
예제 #7
0
        public static IGameProviderApi ProvideGameProviderApi()
        {
            if (gameProviderApi == null)
            {
                var networkConfiguration = NetworkConfiguration.GetInstance();
                if (networkConfiguration.IsProduction())
                {
                    gameProviderApi = HttpGameProviderApi.GetInstance();
                }
                else
                {
                    gameProviderApi = DummyGameProviderApi.GetInstance();
                }
            }

            return(gameProviderApi);
        }
예제 #8
0
        public static IAuthenticatorApi ProvideAuthenticatorApi()
        {
            if (authenticatorApi == null)
            {
                var networkConfiguration = NetworkConfiguration.GetInstance();
                if (networkConfiguration.IsProduction())
                {
                    authenticatorApi = HttpAuthenticatorApi.GetInstance();
                }
                else
                {
                    authenticatorApi = DummyAuthenticatorApi.GetInstance();
                }
            }

            return(authenticatorApi);
        }
예제 #9
0
        private void Awake()
        {
            var networkConfiguration = NetworkConfiguration.GetInstance();

            if (networkConfiguration != null)
            {
                if (networkConfiguration.IsProduction())
                {
                    var dummyScene =
                        GameObject.FindGameObjectWithTag(GameTags.DummySceneTag);
                    if (dummyScene != null)
                    {
                        Destroy(dummyScene);
                    }
                }
            }

            Destroy(gameObject);
        }