Installation & Usage

ServerBytes currently supports C# clients.

Installation

.NET

To install the ServerBytes client in a .net application, add the nuget package:

ServerBytes.Client 1.1.0 (latest)

Unity3d

To install the ServerBytes client in an Unity3d game, add the unity package:

ServerBytes.Client 1.1.0 (latest)

Also, configuration change is needed. In Unity3d window, click Edit -> Project Settings -> Player -> Other Settings -> set Api Compatibility Level to .NET 4.x

To add ServerBytes client to your game, just drag&drop or import unity package in your Unity game:

Usage

To use ServerBytes, you need to register plugins first, and then start the connection.

In this example, we are registering the ServerBytes Authentication plugin for development environment:

var pluginHost = ClientFactory.GetPluginHost(appKey, "development");
var authFactory = new AuthenticationServiceFactory(pluginHost);
// Instantiate other plugins here

Note that appKey parameter. This is the application key, which can be obtained on the application details page.

To configure the client, pass the plugin host instance into ClientFactory.GetClient or UnityClientFactory.GetClient method in case of Unity3d. Next, attach event handlers to the client, and then start connecting.

Client = UnityClientFactory.GetClient(host);
Client.OnConnected += Client_OnConnected;
Client.OnFailedToConnect += Client_OnFailedToConnect;
Client.OnDisconnected += Client_OnDisconnected;
Client.Connect();

Event handlers can be defined as:

private void Client_OnDisconnected(string errorMessage)
{
}

private void Client_OnFailedToConnect(string errorMessage)
{
}

private void Client_OnConnected()
{
    var authService = authFactory.Create(Client);
}

Note: It is important to create your service once the connection is made to the server.

Check the example of implemented client class here

Next steps

We encourage you to experiment with existing plugins, or even create your own.

results matching ""

    No results matching ""