07/23/2015

GDC and v1.3

Hello there!

For the upcoming GDC Europe, where we will present Stormancer and a few awesome demos, we worked hard on new features, optimization and bug fixing.

As always, everything is available on the public beta server for free, enjoy! However if you need to run Stormancer in production, contact us.

All the samples reference the public server. They can run on private instances too with the right host.

The 1.3 as been tested against 200k msg/s workload , 50MB/s outbound bandwidth and 1000 concurrent players on a single server instance.

Unity3D iOS and Android

The unity3D package now supports both Android & iOS exports. That was not easy, Raknet4 made some difficulties, but we are up and running.

Code source available on github.

C++ client library

The C++ client Library works now on Android. The NDK is a difficult beast, and compiling all our dependencies took more time than we expected. We don't have official C++ iOS support currently and are focusing on GDC, but that's definitely on track now.

Code source available on github. We would be quite happy to get feedback from more experienced C++ developers too. If someone is interested at taking a look at the code? :)

Assets

Put static files in the Assets/Public subfolder of your server application to be able to anonymously download them from the url https://api.stormancer.com/<accountId>/<appName>/_assets/Public/<yourPath>

Sample

The file index.htm located here ( github ) is available online on the following url : https://api.stormancer.com/997bc6ac-9021-2ad6-139b-da63edee8c58/boids/_assets/Public/admintest/index.html

Admin assets

Assets located in the Assets/Admin subfolder are only available for requests containing a valid x-token value. The token can be provided in an x-token header, an x-token query parameter or an x-token cookie.

Admin APIs

0.5 had a nice feature that allowed developers to add in their app APIs available through an authenticated POST HTTP request. That's this stuff that was behind demos like the PHP push demo. Sadly the feature was a little buggy and limited.

So in 1.0, we disabled the feature, went back to the drawing board and finally created the new Admin APIs.

You will need to create Admin plugin to use them (that may be a little awkward, but we will find a way around this), but you now have access to the full power of HTTP (yes, GET, POST, DELETE, PUT are available now, as welle as custom content-types, headers, etc...).

Admin APIs are built on top of Nancy. That means that you will benefit from a lot of the features of this awesome Framework, including the overall straightforwardness of their programming model, routing, parameters binding and content negociation.

Please remember that the feature is young, so we would love any suggestions to improve it.

Sample

 public void Run(IAppBuilder builder)
 {

        var admin = builder.AdminPlugin("test", Stormancer.Server.Admin.AdminPluginHostVersion.V0_1).Name("Test admin page");
        admin.Get["/"] = ctx => "hello world, I am the server!";
         admin.Get["/{msg}"] = parameters => "You asked me : " + parameters.msg;


 }

The code above creates 2 Apis:

  • https://api.stormancer.com/<accountId>/<appName>/_admin/test/
  • https://api.stormancer.com/<accountId>/<appName>/_admin/test/{msg} where msg can be replace by any string.

Server Config

Associate a json configuration object to your app. The json object can be changed at runtime with an API call (Account authentication level) and your app will be notified of the change.

The configuration object can be updated in the Configuration tab of the management portal.

The web API supports GET to read the configuration and PUT to update it. It currently only supports json configuration objects.

Url: https://api.stormancer.com/<accountId>/<appName>/config/config

In the server app :

  var environment = scene.GetComponent<IEnvironment>();
   var v = environment.Configuration.Value; //Get configuration value.
   environment.ConfigurationChanged += (obj,_) =>
   {
        //React to configuration changes.
   };

New server plugin events

We provide events to create Stormancer plugins that plug in more parts of the application lifecycle.

public class HostPluginBuildContext
{
    /// <summary>
    /// Fires just before the scene template is applied to a new scene.
    /// </summary>
    public Action<ISceneHost> SceneCreating { get; set; }

    /// <summary>
    /// Fires just after the scene template is applied to a new scene.
    /// </summary>
    public Action<ISceneHost> SceneCreated { get; set; }

    /// <summary>
    /// Fires after a new scene has started.
    /// </summary>
    public Action<ISceneHost> SceneStarted { get; set; }

    /// <summary>
    /// Fires when the server host is starting. 
    /// </summary>
    public Action<IHost> HostStarting { get; set; }

    /// <summary>
    /// Fires when the server host is shutting down
    /// </summary>
    public Action<IHost> HostShuttingDown { get; set; }
}

Application metadata

You can now programmatically add metadata to the application on startup. The metadata are included in the response to a Get application web API call and can be leverage by modules and plugin to improve automation.

It's current main use is currently to power extensibility of the management portal, but it's up to you to use it in other imaginative ways.

Metadta can be updated by a plugin in the HostStarting plugin event.

Synchronized clock

In videogames, we often need a way to timestamp player actions in a way that is synchronized between players and the server itself. That's exactly the role of the synchronized clock.

It provides a precise, synchronized clock between all the players and the server that can be use to timestamp events and code lag compensation algorithms.

Furthermore, the clock provides regularly updated ping values.

On the server, the clock is available using the IEnvironment component :

var environment = scene.GetComponent<IEnvironment>();
var clock = environment.Clock;
var ping = environment.LastPing;

On clients the clock is directly exposed on the Client object:

var clock = client.Clock;
var ping = client.LastPing;

Peer details & GeoIP (beta)

You can now access simple GeoIP data in the IPeerDetailsService component. It uses the free Maxmind GeoLite database, but you could replace it with a full fledged GeoIP DB on private deployments.

It's a beta feature as in "May change in any way we might need, even in breaking way, much more than the rest of Stormancer".

It's our first cluster plugin, the code will be available as opensource as soon as we find enough time to cleanup the cluster plugin programing API to make sure that the stuff is not obsolete the second we release it.

To use it :

var peerService = scene.GetComponent<IPeerInfosService>();
var details = await peerService.GetPeerDetails(ctx.RemotePeer));

And the PeerDetails object :

public class PeerDetails
{
    /// <summary>
    /// Continent code.
    /// </summary>
    public string Continent { get; set; }

    /// <summary>
    /// A Datetime instance containing the connection time of the peer.
    /// </summary>
    public DateTime ConnectedOn { get; set; }

    /// <summary>
    /// Ip address of the peer.
    /// </summary>
    public string IPAddress { get; set; }


    /// <summary>
    /// A boolean value indicating whether the server is able to provide Geo IP data.
    /// </summary>
    public bool GeoIpEnabled { get; set; }

    /// <summary>
    /// Country code.
    /// </summary>
    public string Country { get; set; }

    /// <summary>
    /// City code.
    /// </summary>
    public string City { get; set; }

    /// <summary>
    /// Latitude of the peer's location.
    /// </summary>
    public double? Latitude { get; set; }

    /// <summary>
    /// Longitude of the peer's location.
    /// </summary>
    public double? Longitude { get; set; }

    /// <summary>
    /// Time zone of the peer.
    /// </summary>
    public string TimeZone { get; set; }
}

Application details & management keys

Get details about the current application, including application level authentication keys required to create a Stormancer.Management.Client.ApplicationClient instance.

This will allow you to perform any web API operations that require Application level auth without having to provide the key in the app configuration. Your app is trustful enough, isn't it?

var environment = scene.GetComponent<IEnvironment>();
var appInfos = await environment.GetApplicationInfos();

The ApplicationInfos object :

public class ApplicationInfos
{
    /// <summary>
    /// Id of the active deployment for the application
    /// </summary>
    public string ActiveDeployment { get; set; }

    /// <summary>
    /// A string containing the id of the current deployment.
    /// </summary>
    public string DeploymentId { get; set; }

    /// <summary>
    /// A string containing the name of the current application.
    /// </summary>
    public string ApplicationName { get; set; }

    /// <summary>
    /// A string containing the id of the account containing the application.
    /// </summary>
    public string AccountId { get; set; }

    /// <summary>
    /// A string containing the primary access key of the application.
    /// </summary>
    public string PrimaryKey { get; set; }

    /// <summary>
    /// A string containing the secondary access key of the application.
    /// </summary>
    public string SecondaryKey { get; set; }
}

ActiveDeploymentChanged event

Event fired when the active deployment changes (ie the current app is no longer the active deployment).

Useful to inform players they are not on the last version of the server anymore and that they might want to restart the game. Or for any kind of similar behavior, including "kick them all" and let the Garbage collector do its magic.

environment.ActiveDeploymentChanged+=(obj,args)=>
{
   var isActive = args.IsActive;
   var activeDeploymentId = args.ActiveDeploymentId;
}

List and stop hosts

You can now list hosts running on Stormancer for a given application and stop them, for instance to force a restart. The api won't instantly stop the process, but will fire the ShuttingDown event on all the scènes running on the host. The process will be stopped when it's elligible for garbage collection (ie when all players will be disconnected).

Web Apis

GET: "http://api.stormancer.com/{accountId}/{applicationName}/_hosts/" to list running hosts.

DELETE: "http://api.stormancer.com/{accountId}/{applicationName}/hosts/" to stop the current active host DELETE: "http://api.stormancer.com/{accountId}/{applicationName}/hosts/{hostId}" to stop a specific running host.


No Comments

Post Reply

You must sign in to comment.