Example #1
0
        protected override void OnInitialize()
        {
            Mst.Events.Invoke(MstEventKeys.showLoadingInfo, "Connecting to master... Please wait!");

            // If we want to use default credentials for signin or signup views
            if (useDefaultCredentials && Mst.Runtime.IsEditor)
            {
                var credentials = new MstProperties();
                credentials.Set(MstDictKeys.USER_NAME, defaultUsername);
                credentials.Set(MstDictKeys.USER_PASSWORD, defaultPassword);
                credentials.Set(MstDictKeys.USER_EMAIL, defaultEmail);

                Mst.Events.Invoke(MstEventKeys.setSignInDefaultCredentials, credentials);
                Mst.Events.Invoke(MstEventKeys.setSignUpDefaultCredentials, credentials);
            }

            Mst.Client.Auth.RememberMe = rememberUser;

            MstTimer.WaitForSeconds(0.5f, () =>
            {
                // Listen to connection events
                Connection.AddConnectionListener(OnClientConnectedToServer);
                Connection.AddDisconnectionListener(OnClientDisconnectedFromServer, false);

                if (!Connection.IsConnected && !Connection.IsConnecting)
                {
                    Connector.StartConnection();
                }
            });
        }
Example #2
0
        protected override void Awake()
        {
            if (doNotDestroyOnLoad)
            {
                // Find another instance of this behaviour
                var clientInstance = FindObjectOfType <RoomClient>();

                if (clientInstance != this)
                {
                    Destroy(gameObject);
                    return;
                }

                DontDestroyOnLoad(gameObject);
            }

            base.Awake();

            // Get connection to master
            masterConnection = Mst.Connection;

            // Create room client connection
            Connection = ConnectionFactory();

            // Listen to connection statuses
            Connection.AddConnectionListener(OnClientConnectedToRoomServer, false);
            Connection.AddDisconnectionListener(OnClientDisconnectedFromRoomServer, false);

            // If master IP is provided via cmd arguments
            masterIP = Mst.Args.AsString(Mst.Args.Names.MasterIp, masterIP);
            // If master port is provided via cmd arguments
            masterPort = Mst.Args.AsInt(Mst.Args.Names.MasterPort, masterPort);
        }
Example #3
0
 protected override void OnInitialize()
 {
     if (Mst.Options.Has(MstDictKeys.autoStartRoomClient))
     {
         Mst.Events.Invoke(MstEventKeys.showLoadingInfo, "Connecting to room... Please wait!");
         Connection.AddConnectionListener(OnConnectedToMasterServerEventHandler);
     }
 }
Example #4
0
 protected override void OnInitialize()
 {
     // This will start client connection to room server if it came from menu with global parameter AUTOSTART_ROOM_CLIENT
     if (Mst.Options.Has(MstDictKeys.AUTOSTART_ROOM_CLIENT))
     {
         Mst.Events.Invoke(MstEventKeys.showLoadingInfo, "Connecting to room... Please wait!");
         Connection.AddConnectionListener(OnConnectedToMasterServerEventHandler);
     }
 }
        protected override void OnInitialize()
        {
            if (Msf.Client.Rooms.ForceClientMode)
            {
                return;
            }

            // Start waiting empty room termination
            if (!terminateRoomWhenLastPlayerQuits && terminateEmptyRoomInSeconds > 0)
            {
                StartCoroutine(StartEmptyIntervalsCheck(terminateEmptyRoomInSeconds));
            }

            // Get mirror network manager
            MirrorNetworkManager = NetworkManager.singleton;

            // Start listening to OnServerStartedEvent of our MirrorNetworkManager
            if (NetworkManager.singleton is MirrorNetworkManager manager)
            {
                manager.OnServerStartedEvent      += OnMirrorServerStartedEventHandler;
                manager.OnClientDisconnectedEvent += OnMirrorClientDisconnectedEvent;
                manager.OnServerStoppedEvent      += OnMirrorServerStoppedEventHandler;
            }
            else
            {
                logger.Error("We cannot register listeners of MirrorNetworkManager events because we cannot find it onscene");
            }

            // Set room oprions
            roomOptions = SetRoomOptions();

            // Set port of the Mirror server
            SetPort(roomOptions.RoomPort);

            // Add master server connection and disconnection listeners
            Connection.AddConnectionListener(OnConnectedToMasterServerEventHandler, true);
            Connection.AddDisconnectionListener(OnDisconnectedFromMasterServerEventHandler, false);

            // If connection to master server is not established
            if (!Connection.IsConnected && !Connection.IsConnecting)
            {
                Connection.Connect(masterIp, masterPort);
            }
        }
Example #6
0
        protected override void OnInitialize()
        {
            if (Mst.Client.Rooms.ForceClientMode)
            {
                return;
            }

            // Get mirror network manager
            RoomNetworkManager = NetworkManager.singleton;

            // Start listening to OnServerStartedEvent of our MirrorNetworkManager
            if (RoomNetworkManager is RoomNetworkManager manager)
            {
                manager.OnServerStartedEvent      += OnMirrorServerStartedEventHandler;
                manager.OnClientDisconnectedEvent += OnMirrorClientDisconnectedEvent;
                manager.OnServerStoppedEvent      += OnMirrorServerStoppedEventHandler;
            }
            else
            {
                logger.Error("We cannot register listeners of MirrorNetworkManager events because we cannot find it onscene");
            }

            // Set room oprions
            roomOptions = SetRoomOptions();

            // Set port of the Mirror server
            SetPort(roomOptions.RoomPort);

            // Add master server connection and disconnection listeners
            Connection.AddConnectionListener(OnConnectedToMasterServerEventHandler, true);
            Connection.AddDisconnectionListener(OnDisconnectedFromMasterServerEventHandler, false);

            // If connection to master server is not established
            if (!Connection.IsConnected && !Connection.IsConnecting)
            {
                Connection.UseSsl = MstApplicationConfig.Instance.UseSecure;
                Connection.Connect(masterIp, masterPort);
            }
        }
Example #7
0
        protected override void Start()
        {
            if (Mst.Client.Rooms.ForceClientMode)
            {
                return;
            }

            // Set room oprions
            roomOptions = SetRoomOptions();

            // Set port of the Mirror server
            SetPort(roomOptions.RoomPort);

            // Add master server connection and disconnection listeners
            Connection.AddConnectionListener(OnConnectedToMasterServerEventHandler, true);
            Connection.AddDisconnectionListener(OnDisconnectedFromMasterServerEventHandler, false);

            // If connection to master server is not established
            if (!Connection.IsConnected && !Connection.IsConnecting)
            {
                Connection.Connect(masterIp, masterPort);
            }
        }
        protected override void OnInitialize()
        {
            FindOrCreateMasterConnector();

            signinView            = ViewsManager.GetView <SignInView>("SigninView");
            signupView            = ViewsManager.GetView <SignUpView>("SignupView");
            passwordResetView     = ViewsManager.GetView <PasswordResetView>("PasswordResetView");
            passwordResetCodeView = ViewsManager.GetView <PasswordResetCodeView>("PasswordResetCodeView");
            emailConfirmationView = ViewsManager.GetView <EmailConfirmationView>("EmailConfirmationView");

            Msf.Client.Auth.RememberMe = rememberUser;

            MsfTimer.WaitForEndOfFrame(() =>
            {
                if (useDefaultCredentials && Application.isEditor)
                {
                    if (signinView)
                    {
                        signinView.SetInputFieldsValues(defaultUsername, defaultPassword);
                    }

                    if (signupView)
                    {
                        signupView.SetInputFieldsValues(defaultUsername, defaultEmail, defaultPassword);
                    }
                }

                Connection.AddConnectionListener(OnClientConnectedToServer);
                Connection.AddDisconnectionListener(OnClientDisconnectedFromServer, false);

                if (!Connection.IsConnected && !Connection.IsConnecting)
                {
                    Msf.Events.Invoke(MsfEventKeys.showLoadingInfo, "Connecting to master... Please wait!");
                    clientToMasterConnector.StartConnection();
                }
            });
        }