C# API for Unity 5 beta, available!

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Post Reply
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

C# API for Unity 5 beta, available!

Post by Lapo »

Hello,
we have just released version 1.6.0beta of the Unity/C# API that support the new WebGL exporter in the upcoming Unity 5 (currently in beta).

If you're planning to use the WebGL exporter or you're already working with the Unity 5 beta you can download the API and test them in your Unity 5 project:
http://www.smartfoxserver.com/download/sfs2x#p=client

We will also highly appreciate your feedback, so if you find any problems please let us know in this section of the forum.

NOTE #1:
Make sure to read and follow the instructions in the README.txt file contained in the beta API package.

NOTE #2:
For all developers working in Unity 4.x there's no need advantage in using this beta release, as it solely addresses the Unity 5 WebGL exporter.

Enjoy!
Lapo
--
gotoAndPlay()
...addicted to flash games
creat326
Posts: 87
Joined: 13 Jun 2010, 09:50

Re: C# API for Unity 5 beta, available!

Post by creat326 »

Hi

I believe this is a bug on this smartfox.dll for unity. I've been using the older dll for ages without any problem and today I decided to upgrade the server and clients to the latest version.
The issue is that it seems that udp is never inited.
I have the usual
connect
login -> server extension custom login that returns a
ISFSObject outData = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_OUT_DATA);
outData.putUtfString(SFSConstants.NEW_LOGIN_NAME, nick);

then on the client onLogin I have the
smartFox.InitUDP(ConnectionIP, Port);

all of this is called as usual, now the problem is that my OnUdpInit method is never called. It's setup with the usual
smartFox.AddEventListener(SFSEvent.UDP_INIT, OnUdpInit);

The funny thing is that on the server log there is nothing, I see no udp trying to connect or anything like that. I have both tcp/udp listening to 443 to make sure it's not blocked.

Am I missing something? As I said, this was just fine before the update.
creat326
Posts: 87
Joined: 13 Jun 2010, 09:50

Re: C# API for Unity 5 beta, available!

Post by creat326 »

Ok, I decompiled the dll and found this at the beginning of InitUDP

public void InitUDP(string udpHost, int udpPort)
{
if (this.socketClient.UdpManager == null)
{
this.Logger.Warn(new string[]
{
"UDP protocol not supported."
});
return;
}

I get that error printed out all the time: UDP protocol not supported.

Then I searched for that UdpManager and it's actually set at the end of that block... in short, UdpManager is ALWAYS null.

Can you please send a fix? i'm stuck because of this on my unity development :(
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: C# API for Unity 5 beta, available!

Post by Bax »

I confirm that there was an issue in the API related to UDP initialization.
Now it has been fixed, so please download again the beta package of the API from this page: http://www.smartfoxserver.com/download/sfs2x#p=client
Paolo Bax
The SmartFoxServer Team
spartacan
Posts: 1
Joined: 13 Apr 2015, 17:12

Re: C# API for Unity 5 beta, available!

Post by spartacan »

I may have found another bug in the WebGL version of smartfox.dll. It appears to occur when calling Sfs2X.Entities.Data.SFSObjectLite.GetByteArray (System.String key). Here's the stack trace:

InvalidCastException: Unable to cast object of type 'SFSArrayLite' to type 'ISFSObject'.
Sfs2X.Entities.Data.SFSObject.GetValue[Object] (System.String key)
Sfs2X.Entities.Data.SFSObject.GetSFSObject (System.String key)
Sfs2X.Entities.Data.SFSObjectLite.GetByteArray (System.String key)
NetworkBlockUpdate..ctor (ISFSObject data)
NetworkBehavior.HandleJoinRoom (ISFSObject data)
NetworkBehavior.OnExtensionResponse (Sfs2X.Core.BaseEvent evt)
Sfs2X.Core.EventListenerDelegate.Invoke (Sfs2X.Core.BaseEvent evt)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt)
Sfs2X.SmartFox.ProcessEvents ()
NetworkBehavior.FixedUpdate ()
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: C# API for Unity 5 beta, available!

Post by Bax »

Byte arrays are not supported when using WebGL. We will (possibly) remove the methods to get/put byte arrays in the final API.
As a workaround you should convert the byte array to an array of integers, and convert it back on the other side.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: C# API for Unity 5 beta, available!

Post by Bax »

A new version of the C# API (beta 3) is available on the API download page: http://www.smartfoxserver.com/download/sfs2x#p=client
We finalized the WebGL support in Unity.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: C# API for Unity 5 beta, available!

Post by Bax »

The final C# API v1.6.0 is now available.
Paolo Bax
The SmartFoxServer Team
Post Reply