11/07/2014

v0.5.0 is out!

A new version of Stormancer is out, try it right now!

What’s new

Some new things in this release:

  • A new OnConnecting server-side event
  • Better error management in JavaScript
  • Modifications on the Stormancer Unity Package
  • Compatiblity with the  iOS export in our Unity Package
  • As always, some bug corrections

 

Server-side

We added a new OnConnecting event on our server-side scenes. It’s distinct from the OnConnect event because it fires right before the user connects to the scene, and not after. That’s useful because that way, the new user in not yet present in the Connections property, and if you broadcast a message, the new user will not receive it.

this.AssociatedObject.OnConnecting.Add(async connection => 
    //only previously connected users will receive this 
    await AssociatedObject.Broadcast("test", "new user connecting."));

this.AssociatedObject.OnConnect.Add(async connection => 
    //all users will receive this 
    await AssociatedObject.Broadcast("test", "new user connected."));

You can also use this feature to refuse a connection by throwing a ClientException.

this.AssociatedObject.OnConnecting.Add(async connection =>
    {
        throw new ClientException("Connection refused!");
    });

The new Stormancer Core library is available on Nuget.

JavaScript

There are a couple of bug fixes, but the main new features for this version are inside the new state member of the Stormancer clients.

var state = client.state;

This ClientState object exposes the following:

  • A state() method, which returns a member from the Stormancer.ConnectionState object. Possible values are:
    Stormancer.ConnectionState.connecting; // 0
    Stormancer.ConnectionState.connected; // 1
    Stormancer.ConnectionState.reconnection; // 2
    Stormancer.ConnectionState.disconnected; // 4
    Use the state() to make sure the client is not in an invalid state before performing an operation.
if(client.state.state() != Stormancer.ConnectionState.disconnected){
  // do things
}
else{
  // handle disconnection
}
  • A stateChanged event to be notified if the connection’s state changes.
client.state.stateChanged(function(s){
  if (s == Stormancer.ConnectionState.disconnected){
    alert("We got disconnected from Stormancer!");
  }
});
  • A connectionError event to be notified if the underlying connection throws an error.
client.state.connectionError(function(error){
  alert("something unexpected happened :" + error);
});

You can grab the last version of our javascript library from our wiki.

Unity

Our unity package is evolving. We included UniRX, removed Json.Net and made a iOS-compatible version.

With UniRx

We have always used a version of Reactive Extensions in our plugin, but the one we were using had some compatibility issues with Unity, and did not work at all with the iOS export (for AOT reasons, as is often the case when you have an iOS compatibility issue). Instead of rewriting it from scratch, we switched to UniRX, which is exactly what we needed: a Reactive Extensions implementation for Unity.

Without Json.Net

Json.Net had compatibility issues with iOS,  and we were already using MessagePack for our message serialization, so we decided to get rid of Json.Net altogether. It was made possible thanks to a change in our server infrastructure, so the new Unity package is not compatible with older deployments.

Working on iOS

Sormancer is heavily using code emission to be lightning-fast. Sadly, this is not possible on iOS exports. We had to resort to other techniques to keep having good performances in an environment where code emission is not allowed at all. This led us to create a Unity package specifically for targeting iOS. Its performances are good, but not as great as our standard package. The good news is that this package works for all exports, and not only for iOS. In the future we will create an unique package with the better of both worlds: awesome performance and iOS compatibility. Stay tuned for our updates!

You can grab our new Unity packages on our wiki.

 

Let us know

We hope you’ll enjoy these new features. Make sure to tell us what you think about them and what you would want us to implement next.


No Comments

Post Reply

You must sign in to comment.