[NEW] .Net/Unity API 1.1 available

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

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

[NEW] .Net/Unity API 1.1 available

Postby Lapo » 27 Feb 2009, 10:43

Hello,
today we release version 1.1 of the Unity API!
The new release fixes most of the issues submitted to Thomas in the past months in this board plus it adds new great examples.

There are now 4 from-zero-to-hero tutorials, including source code and detailed comments:

1- Simple Connect
very basic introduction to the usage of the API

2- Simple Lobby
guides you through the creation of a simple Lobby with chat etc...

3- SmartFoxTris
Unity3D version of the tic-tac-toe game, including server side logic

4- SFS Island Demo
realtime interaction in the beautiful Unity demo island!
This one is provided as a separate download due to its size (130Mb)

All the details and download links are found here.


Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 28 Feb 2009, 07:32

I just wanted to chime in with a little more details here also.

The change list for this release is

Code: Select all

* New queue mode for delayed processing of network events. Especially useful in non-thread safe environments

* Bugfix: workaround for a mono bug in the version shipped with Unity. The delimiter of numbers is different for some locales, and that cause problems serializing/deserializing them. Workaround is to enforce en-US number format when reading/writing numbers in the serializer.

* More robust deserializing of XML. Could e.g. throw an unhandled exception when meeting unexpected empty strings

* Fixed bug in GetRoomByName iterating over hashtable

* Updated bugs in documentation when iterating over hashtables


The new queue mode needs a few words. The aim is to get Unity (or other non-thread safe environemtns) to decide when they want delegates to be called as well as doing it from the game thread.

As it is in non-queue mode (which the API defaults to for backwards compatibility) it is the thread with the TCP connection that when it receives data also calls the delegate - at the time when it gets the data.

If Unity e.g. was currently iterating over a ArrayList of chat messages, and the API suddenly updated the same ArrayList then you would get an error.

This is what the new queue mode handles - it queues up all network events internally - and when you form your game call the ProcessEventQueue() method, then it empties that queue.

It is thus very easy to use and very transparent for the developer. Simply do this in Unity (or other clients) and your delegates will be called as usual. No other changes to the client code compared to previous examples/tutorials:

Code: Select all

smartFox = new SmartFoxClient();
smartFox.runInQueueMode = true;

void FixedUpdate() {
   smartFox.ProcessEventQueue();
}


The API will right there totally empty all queued up messages from the server.

Sending messages is still instant - the queue mode is only on the receiving/processing side.

If you check the tic-tac-toe tutorial as well as the island demo, both of these use this new queue mode.

And I would actually say that it is _the_ preferred mode for usage in Unity.

It is naturally up to you when you want the processing to happen. FixedUpdate is a good place, but it could also happen for each frame (Update) or whenever you want.

Shoot away with questions if you have any!

/Thomas
zante
Posts: 7
Joined: 13 Nov 2009, 19:02

Postby zante » 13 Nov 2009, 19:05

Just got this up and running, well done for providing a simple solution to a complex problem.

Great work guys.

No questions as once it's all up and running, it's down to unity to do the rest. Just trying to get names to appear above people's avatars at the moment.

Great stuff.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 14 Nov 2009, 08:45

Hi,
thanks and welcome :)

Just wanted to mention that the latest version of the API is 1.2.3 and it's found here.
Lapo

--

gotoAndPlay()

...addicted to flash games
zante
Posts: 7
Joined: 13 Nov 2009, 19:02

Postby zante » 14 Dec 2009, 12:17

How would I go about adding an identifier for an avatar type? Something that could be used for a character selection screen?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 14 Dec 2009, 17:26

A User Variable would do it.
User Varaibles are custom values that every user carries around and are publicly available to other clients to read.
Check the documentation for more details.
Lapo

--

gotoAndPlay()

...addicted to flash games
zante
Posts: 7
Joined: 13 Nov 2009, 19:02

Postby zante » 26 Apr 2010, 09:33

Lapo,

Which piece of documentation refers to this, I'm currently learning by reverse engineering the multiplayer island demo.

A google search for +smartfox +unity "user variable" returns nothing.

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 15 guests