sfs x2 use webgl

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

debbyGold
Posts: 4
Joined: 01 Feb 2018, 08:38

sfs x2 use webgl

Postby debbyGold » 11 Feb 2018, 08:50

Hello,

I use sfs x2 in unity and trying to build in webgl.

when i build in webgl All SFS Events( SFSEvent.CONNECTION, SFSEvent.LOGIN, SFSEvent.ROOM_JOIN) are Not caught.

my code is:

Code: Select all

               cfg = new ConfigData();
                cfg.Host = ip;
                cfg.Port = port;
                cfg.HttpPort = httpPort;
                cfg.HttpsPort = httpsPort;
                cfg.Zone = zone;

               #if !UNITY_WEBGL
                 SFS = new SmartFox();
                #else
                                SFS = new SmartFox(UseWebSocket.WS_BIN);
                #endif
                Debug.Log("new SmartFox()!");
                SFS.ThreadSafeMode = false;
                SFS.ProcessEvents();
                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, OnServerResponse);
                SFS.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
                SFS.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
                SFS.AddEventListener(SFSEvent.SOCKET_ERROR, OnSocketError);
                SFS.AddEventListener(SFSEvent.CRYPTO_INIT, OnCryptoInit);
               SFS.Connect(cfg);

 void OnConnection(BaseEvent evt)
        {
          bool success = (bool)evt.Params["success"];
            if ((bool)evt.Params["success"])
            {
                SFS.Send(new Sfs2X.Requests.LoginRequest(username,password,zone));
            }


but after I build unity with webgl it never arrived OnConnection.

someone know What is the reason for this?

Thanks Debby.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: sfs x2 use webgl

Postby Lapo » 12 Feb 2018, 08:41

Hi,
I would say the cause is this line:

Code: Select all

SFS.ThreadSafeMode = false;

You don't need to change the "thread safe mode" for WebGL.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 67 guests