internal IEnumerator InitCrypto()
 {
     lock (smartFoxLock)
     {
         return(smartFox.InitCrypto());
     }
 }
    //----------------------------------------------------------
    // SmartFoxServer event listeners
    //----------------------------------------------------------

    private void OnConnection(BaseEvent evt)
    {
        if ((bool)evt.Params["success"])
        {
            trace("Connection established successfully");
            trace("SFS2X API version: " + sfs.Version);
            trace("Connection mode is: " + sfs.ConnectionMode);

            // Enable disconnect button
            button.interactable = true;
            buttonLabel.text    = "DISCONNECT";

                        #if !UNITY_WEBGL
            // Enable protocol encryption on non-WebGL builds only (WebGL build uses WSS protocol already)
            if (useEncryption)
            {
                // Initialize encryption
                // All builds except Windows Store require a coroutine
                                #if UNITY_EDITOR || !UNITY_WINRT_8_1
                StartCoroutine(sfs.InitCrypto());
                                #else
                sfs.InitCrypto();
                                #endif
            }
            else
            {
                // Attempt login
                login();
            }
                        #else
            // Attempt login
            login();
                        #endif
        }
        else
        {
            trace("Connection failed; is the server running at all?");

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