Page 1 of 1

The type 'SmartFox' exists in both

Posted: 11 Aug 2019, 04:03
by gg
Hi, I have a project based on the Tris Unity example and it is building fine for standalone and Android, but when I build for WebGL, it's giving me this error:
Any ideas?

Assets\Scripts\SmartFoxConnection.cs(13,19): error CS0433: The type 'SmartFox' exists in both 'SmartFox2X, Version=1.7.9.0, Culture=neutral, PublicKeyToken=null' and 'SmartFox2X_WebGL, Version=1.7.9.0, Culture=neutral, PublicKeyToken=null'

Re: The type 'SmartFox' exists in both

Posted: 12 Aug 2019, 07:22
by Bax
It seems you selected the wrong platforms to associate the WebGL API to in the Inspector panel when clicking on the DLL.
Please make sure you follow the instructions on this page: http://docs2x.smartfoxserver.com/Gettin ... harp#unity

Re: The type 'SmartFox' exists in both

Posted: 13 Aug 2019, 06:48
by gg
ah, I missed that!

But now I am getting this error and I can't build even for Windows nor Android :(

Code: Select all

Assets\Scripts\GameController.cs(8,7): error CS0246: The type or namespace name 'Sfs2X' could not be found (are you missing a using directive or an assembly reference?)


I kept reimporting and checking/unchecking boxes in SmartFox2X_UWP and SmartFox2X_WebGL and still it cannot recognise 'Sfs2x'

Re: The type 'SmartFox' exists in both

Posted: 13 Aug 2019, 08:02
by Bax
Select all three DLLs we provide in our API package, one by one:
- for SmartFox2X.dll, check everything except WebGL and WSAPlayer (Universal Windows Platform) --- SEE PICTURE BELOW;
- for SmartFox2X_WebGL.dll, only check WebGL;
- for SmartFox2X_UWP.dll (if you use it), only check WSAPlayer.
That should work.

Image

Re: The type 'SmartFox' exists in both

Posted: 17 Aug 2019, 03:29
by gg
Thank you, I am able to build in WebGL now. But it is not able to connect to the server from the browser (it says

Code: Select all

"Connection failed; is the server running at all?"


And when it runs from Unity, it gives this error

Code: Select all

InvalidOperationException: The current state of the connection is not Open.
WebSocketSharp.WebSocket.SendAsync (System.Byte[] data, System.Action`1[T] completed) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.Sockets.WebSocketHelper.Send (System.Byte[] buffer) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.Sockets.WebSocketLayer.Write (System.Byte[] data) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.WSIOHandler.WriteBinaryData (Sfs2X.Core.PacketHeader header, Sfs2X.Util.ByteArray binData) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.WSIOHandler.OnDataWrite (Sfs2X.Bitswarm.IMessage message) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.WSProtocolCodec.OnPacketWrite (Sfs2X.Bitswarm.IMessage message) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Bitswarm.WebSocketClient.Send (Sfs2X.Bitswarm.IMessage message) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.SmartFox.Send (Sfs2X.Requests.IRequest request) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.SmartFox.SendHandshakeRequest (System.Boolean isReconnection) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.SmartFox.OnSocketConnect (Sfs2X.Core.BaseEvent e) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Rethrow as Exception: Error dispatching event connect: The current state of the connection is not Open.   at WebSocketSharp.WebSocket.SendAsync (System.Byte[] data, System.Action`1[T] completed) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.Sockets.WebSocketHelper.Send (System.Byte[] buffer) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.Sockets.WebSocketLayer.Write (System.Byte[] data) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.WSIOHandler.WriteBinaryData (Sfs2X.Core.PacketHeader header, Sfs2X.Util.ByteArray binData) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.WSIOHandler.OnDataWrite (Sfs2X.Bitswarm.IMessage message) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.WSProtocolCodec.OnPacketWrite (Sfs2X.Bitswarm.IMessage message) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Bitswarm.WebSocketClient.Send (Sfs2X.Bitswarm.IMessage message) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.SmartFox.Send (Sfs2X.Requests.IRequest request) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.SmartFox.SendHandshakeRequest (System.Boolean isReconnection) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.SmartFox.OnSocketConnect (Sfs2X.Core.BaseEvent e) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Bitswarm.WebSocketClient.DispatchEvent (Sfs2X.Bitswarm.BitSwarmEvent evt) (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Bitswarm.WebSocketClient.OnSocketConnect () (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.Sockets.WebSocketLayer.CallOnConnect () (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.Core.Sockets.WebSocketLayer.ProcessState () (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
Sfs2X.SmartFox.ProcessEvents () (at <6e4dfbfef0ea44b78882cd0780df98cd>:0)
LoginController.Update () (at Assets/Scripts/LoginController.cs:66)


When I switch my build back to Windows or Android, it runs fine

Re: The type 'SmartFox' exists in both

Posted: 17 Aug 2019, 11:34
by Bax
Make sure that websocket is properly configured in your server. Go to the AdminTool's Server Configurator module, Web server tab and check if it is configured like this:

Image

Re: The type 'SmartFox' exists in both

Posted: 18 Aug 2019, 03:55
by gg
woooo thank you, that did it! "Enable WS/WSS" was not checked