Example #1
0
        public void Connect()
        {
            Debug.Log("Connect");

            if (smartFox == null || !smartFox.IsConnected)
            {
                // Set connection parameters
                ConfigData cfg = new ConfigData();

                cfg.Host = SCG_Host;

#if !UNITY_WEBGL
                cfg.Port = Convert.ToInt32(SCG_TcpPort);
#else
                cfg.Port = Convert.ToInt32(SCG_WsPort);
#endif

                cfg.Zone = SCG_Zone;

                cfg.Debug = true;

                // Connect to SFS2X
                smartFox.Connect(cfg);
            }
            else
            {
                // DISCONNECT

                // Disconnect from SFS2X
                smartFox.Disconnect();
            }
        }
        private void OnLoginError(BaseEvent evt)
        {
            var message = (string)evt.Params["errorMessage"];

            GD.Print($"Login error; message={message}");
            _sfs.Disconnect();
        }
Example #3
0
 void OnApplicationQuit()
 {
     if (SfsReady)
     {
         sfs.Disconnect();
         print("Disconnected");
     }
 }
Example #4
0
 void OnApplicationQuit()
 {
     // Always disconnect before quitting
     if (sfs != null && sfs.IsConnected)
     {
         sfs.Disconnect();
     }
 }
Example #5
0
    private void OnLoginError(BaseEvent evt)
    {
        // Disconnect
        sfs.Disconnect();

        // Remove SFS2X listeners and re-enable interface
        reset();

        // Show error message
        Debug.Log("Login failed: " + (string)evt.Params["errorMessage"]);
    }
Example #6
0
    }    //end

    //-----------------------------------------------------------------------ON Button Clicked

    public void OnLogOutButtonClicked()
    {    //on logoutbuton clicked this function called
        // Disconnect from server
        if (sfs != null && sfs.IsConnected)
        {
            sfs.Disconnect();
        }
        logount.gameObject.SetActive(false);    //close confirn logount form
        Home.gameObject.SetActive(true);        //open home page
        AdminView.gameObject.SetActive(false);  //close admin view page
        MemberView.gameObject.SetActive(false); //closme member view page
    }
Example #7
0
    }    //end

    //-----------------------------------------------------------------------ON Button Clicked

    public void OnLogOutButtonClicked()
    {
        // Disconnect from server
        if (sfs != null && sfs.IsConnected)
        {
            sfs.Disconnect();
        }
        logount.gameObject.SetActive(false);
        Home.gameObject.SetActive(true);
//		AdminView.gameObject.SetActive(false);
//		MemberView.gameObject.SetActive(false);
    }
Example #8
0
 // Handle disconnection automagically
 // ** Important for Windows users - can cause crashes otherwise
 void OnApplicationQuit()
 {
     if (smartFox != null && smartFox.IsConnected)
     {
         smartFox.Disconnect();
     }
 }
Example #9
0
    private void OnLoginError(BaseEvent evt)
    {
        // Disconnect
        sfs.Disconnect();

        // Remove SFS2X listeners and re-enable interface
        reset();

        // Show error message
        errorText.text = "Login failed: " + (string)evt.Params["errorMessage"];
        if (task == LOGIN.FACEBOOK)
        {
            task = LOGIN.DOREGISTERFBINFO;
            Login();
        }
    }
Example #10
0
 private void OnApplicationQuit()
 {
     if (smartFox.IsConnected)
     {
         smartFox.Disconnect();
     }
 }
Example #11
0
    void OnLoginError(BaseEvent evt)
    {
        popup.Show("ERROR IN GUEST LOGIN", "Something went wrong while we tried to login you as a guest, please try again.", true, 0, popup.Hide);

        Debug.Log("Login error: " + evt.Params["errorMessage"] + " - Code: " + evt.Params["errorCode"]);
        sfs.Disconnect();
    }
Example #12
0
 /**
  * Disconnect from the socket when shutting down the game
  */
 public void OnApplicationQuit()
 {
     if (sfs != null)
     {
         sfs.Disconnect();
     }
 }
Example #13
0
 // Handle disconnection automagically
 // ** Important for Windows users - can cause crashes otherwise
 void OnApplicationQuit()
 {
     if (sfs.IsConnected)
     {
         sfs.Disconnect();
     }
 }
Example #14
0
 // Handle disconnection
 // ** Important for Windows users - can cause crashes otherwise
 void OnApplicationQuit()
 {
     if (SFServer.IsConnected)
     {
         SFServer.Disconnect();
     }
 }
Example #15
0
 protected void OnApplicationQuit()
 {
     if (smartFox.IsConnected)
     {
         UnregisterSFSSceneCallbacks();
         smartFox.Disconnect();
     }
 }
Example #16
0
 void OnApplicationQuit()
 {
     RemoveLocalPlayer();
     if (sfs.IsConnected)
     {
         sfs.Disconnect();
     }
 }
Example #17
0
 void OnDestroy()
 {
     //关闭时,断开与服务器连接
     if (sfs != null && sfs.IsConnected)
     {
         sfs.Disconnect();
     }
 }
Example #18
0
 IEnumerator coroutineDisconect()
 {
     sfs.Disconnect();
     while (sfs.IsConnected)
     {
         yield return(new WaitForEndOfFrame());
     }
     Application.Quit();
 }
Example #19
0
 void OnApplicationQuit()
 {
     if (_smartFox.IsConnected)
     {
         Debug.Log("Quit...");
         _smartFox.RemoveAllEventListeners();
         _smartFox.Disconnect();
     }
 }
Example #20
0
    public static void Connect(string uname)
    {
        if (sfs == null || !sfs.IsConnected)
        {
            username = uname;
            // CONNECT

            Debug.Log("Now connecting...");

            // Add listeners
            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

            sfs.AddLogListener(LogLevel.INFO, OnInfoMessage);
            sfs.AddLogListener(LogLevel.WARN, OnWarnMessage);
            sfs.AddLogListener(LogLevel.ERROR, OnErrorMessage);

            //sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
            sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
            //sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
            sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
            //sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdd);

            // Set connection parameters
            ConfigData cfg = new ConfigData();
            cfg.Host = defaultHost;
            cfg.Port = Convert.ToInt32(defaultTcpPort.ToString());
            cfg.Zone = zone;
            //cfg.Debug = true;

            // Connect to SFS2X
            sfs.Connect(cfg);
        }
        else
        {
            // Disconnect from SFS2X
            sfs.Disconnect();
            trace("Disconnected");
        }
    }
Example #21
0
    void OnLoginError(BaseEvent evt)
    {
        _smartFoxServer.Disconnect();

        ResetLogin();

        string errorMessage = "Login failed: " + (string)evt.Params["errorMessage"];

        DebugConsole.Log(errorMessage, "error");
    }
 internal void Disconnect()
 {
     lock (smartFoxLock)
     {
         if (smartFox != null)
         {
             smartFox.Disconnect();
         }
     }
 }
    private void OnLoginError(BaseEvent evt)
    {
        Debug.Log("On Login error");

        sfs.Disconnect();

        reset();

        Debug.Log("Login failed: " + (string)evt.Params["errorMessage"]);
    }
Example #24
0
 private void ShutdownServer()
 {
     if (smartFox != null)
     {
         smartFox.RemoveAllEventListeners();
         if (smartFox.IsConnected)
         {
             smartFox.Disconnect();
         }
     }
 }
Example #25
0
 public static void Disconnect()
 {
     if (sfs != null)
     {
         sfs.RemoveAllEventListeners();
         if (sfs.IsConnected)
         {
             sfs.Disconnect();
         }
     }
 }
Example #26
0
        private void OnLoginError(BaseEvent evt)
        {
            _sfs.Disconnect();

            var user    = (string)evt.Params["user"];
            var message = (string)evt.Params["errorMessage"];
            var code    = (string)evt.Params["errorCode"];

            GD.Print($"Unable to login to {_config.Host} as {user}");
            GD.Print($"code={code}, message={message}");
        }
Example #27
0
        public void Disconnect()
        {
            IsConnected  = false;
            isConnecting = false;
            if (sfs == null)
            {
                return;
            }

            sfs.Disconnect();
            sfs = null;
        }
Example #28
0
    public void Button_Clicked(string buttonName)
    {
        if (buttonName == "LoginButton")
        {
            string EncryptedPW = PasswordUtil.MD5Password(PasswordTB.text);
            SFServer.Send(new LoginRequest(UsernameTB.text, EncryptedPW, GAME_ZONE));
        }
        if (buttonName == "RegisterButton")
        {
            SFServer.Send(new LoginRequest("", "", GAME_ZONE));
            this.RegisterPanel.SetActive(true);
            this.LoginPanel.SetActive(false);
        }
        if (buttonName == "ExitButton")
        {
            SFServer.Disconnect();
            SFServer.RemoveAllEventListeners();
            Application.Quit();
        }
        if (buttonName == "CreateButton")
        {
            InputField UsernameTB        = GameObject.Find("UsernameTB").GetComponent <InputField>();
            InputField PasswordTB        = GameObject.Find("PasswordTB").GetComponent <InputField>();
            InputField ConfirmPasswordTB = GameObject.Find("ConfirmPasswordTB").GetComponent <InputField>();
            InputField EmailTB           = GameObject.Find("EmailTB").GetComponent <InputField>();
            InputField RegistrationKeyTB = GameObject.Find("RegistrationKeyTB").GetComponent <InputField>();

            if (PasswordTB.text == ConfirmPasswordTB.text)
            {
                SFSObject NewAccountObject = new SFSObject();
                NewAccountObject.PutUtfString("Username", UsernameTB.text);
                NewAccountObject.PutUtfString("PasswordHash", PasswordTB.text);
                NewAccountObject.PutUtfString("Email", EmailTB.text);
                NewAccountObject.PutUtfString("RegistrationKey", RegistrationKeyTB.text);

                this.SFServer.Send(new ExtensionRequest("$SignUp.Submit", NewAccountObject));
            }
            else
            {
                if (!MessageText.activeInHierarchy)
                {
                    MessageText.SetActive(true);
                }
                MessageText.GetComponent <Text>().text = "Passwords do not match! Please check and try again.";
            }
        }
        if (buttonName == "BackButton")
        {
            this.LoginPanel.SetActive(true);
            this.RegisterPanel.SetActive(false);
        }
    }
Example #29
0
 // ------------------------------------------------------------------------
 // Die Applikation kontrolliert beenden
 public void ApplicationQuit()
 {
     if (sfs != null && sfs.IsConnected)
     {
         Debug.Log("[" + this.name + "] [" + this.GetType().Name + "] Connection wird beendet");
         sfs.Disconnect();
     }
     else
     {
         if (sfs != null && !sfs.IsConnected)
         {
             Debug.Log("[" + this.name + "] [" + this.GetType().Name + "] Connection ist bereits beendet");
         }
     }
 }
Example #30
0
    public void OnDisconnectClick()
    {
        if (sfs.LastJoinedRoom != null)
        {
            sfs.Send(new Sfs2X.Requests.LeaveRoomRequest(sfs.LastJoinedRoom));
        }
        else
        {
            Debug.LogError("No room was found to leave");
        }

        if (sfs.IsConnected)
        {
            sfs.Disconnect();
        }
    }