Page 1 of 1

C# API for Unity 5 beta, available!

Posted: 12 Dec 2014, 09:51
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!

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

Posted: 08 Apr 2015, 21:17
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.

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

Posted: 08 Apr 2015, 21:53
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 :(

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

Posted: 10 Apr 2015, 12:12
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

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

Posted: 13 Apr 2015, 17:30
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 ()

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

Posted: 14 Apr 2015, 11:47
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.

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

Posted: 29 Apr 2015, 15:50
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.

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

Posted: 09 Jun 2015, 10:05
by Bax
The final C# API v1.6.0 is now available.