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.