The type 'SmartFox' exists in both

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

Moderators: Lapo, Bax

User avatar
gg
Posts: 89
Joined: 19 Sep 2010, 21:16
Contact:

The type 'SmartFox' exists in both

Postby gg » 11 Aug 2019, 04:03

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'
User avatar
Bax
Site Admin
Posts: 4479
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: The type 'SmartFox' exists in both

Postby Bax » 12 Aug 2019, 07:22

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
Paolo Bax
The SmartFoxServer Team
User avatar
gg
Posts: 89
Joined: 19 Sep 2010, 21:16
Contact:

Re: The type 'SmartFox' exists in both

Postby gg » 13 Aug 2019, 06:48

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'
User avatar
Bax
Site Admin
Posts: 4479
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: The type 'SmartFox' exists in both

Postby Bax » 13 Aug 2019, 08:02

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
Paolo Bax
The SmartFoxServer Team
User avatar
gg
Posts: 89
Joined: 19 Sep 2010, 21:16
Contact:

Re: The type 'SmartFox' exists in both

Postby gg » 17 Aug 2019, 03:29

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
User avatar
Bax
Site Admin
Posts: 4479
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: The type 'SmartFox' exists in both

Postby Bax » 17 Aug 2019, 11:34

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
Paolo Bax
The SmartFoxServer Team
User avatar
gg
Posts: 89
Joined: 19 Sep 2010, 21:16
Contact:

Re: The type 'SmartFox' exists in both

Postby gg » 18 Aug 2019, 03:55

woooo thank you, that did it! "Enable WS/WSS" was not checked

Return to “SFS2X Questions”

Who is online

Users browsing this forum: DerikFent, JerodSa, LesAttara and 29 guests