Skip to main content

Getting Started

If you are interested in this project or would like to contribute, please contact me at

Create new game

To create a new game, follow these steps:

  1. Sign in to the LiveOps Tool.
  2. On the sidebar, click on Games settings.
  3. Click on + New game.

New game

  1. Enter the game ID and game name in the provided fields.
  2. Press Create.
  3. Now you can use all features of the services

Javascript game engines

Installing

To install this package, simply type add or install @oneb-sdk/client using your favorite package manager:

  • npm install @oneb-sdk/client
  • yarn add @oneb-sdk/client
  • pnpm add @oneb-sdk/client

Import

The OneB SDK is modulized by clients and commands. To send a request, you only need to import the OneBServicesClient and the commands you need, for example,CallGameScriptCommand:

// ES5 example
const { OneBServicesClient, CallGameScriptCommand } = require("@oneb-sdk/client");
// ES6+ example
import { OneBServicesClient, CallGameScriptCommand } from "@oneb-sdk/client";

Usage

To send a request, you:

  • Initiate client with configuration (e.g. gameId, environment, apiType).
  • Initiate command with input parameters.
  • Call send operation on the client with command object as input

//config service
const client = new OneBServicesClient({ gameId: "DEMO" });

//player login
await client.login({ playerId: "oneb:test1", secretKey: "bimat" });

//get daily rewards information
const getDailyRewardsCommand = new GetBlueprintDataCommand("DailyRewards");
const dailyRewards = await client.send(getDailyRewardsCommand);

//get player profile
const playerProfile = await client.send(new GetPlayerDataCommand('Profile'));

console.log(dailyRewards, playerProfile)

Example

A working example is available here.

Unity engine

Installing

open Unity Package Manager (in Unity's top menu: Window > Package Manager)

Input https://github.com/tdtanvn/oneb-unity.git in Add package from Git URL

package manager unity

Click Add and Close the popup when done

Compile protobuf

Following this instructions to obtain *.cs file

Usage

To send a request, you:

  • Initiate client with configuration (e.g. gameId, environment, apiType).
  • Initiate command with input parameters.
  • Call send operation on the client with command object as input
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// using namespace OneB
using OneB;

public class OnlineManager : MonoBehaviour
{
// Init client
OneBServicesClient client = new OneBServicesClient()
{
GameId = "CG",
Environment = GameEnvironment.DEVELOPMENT,
DebugLogEnabled = true
};

async void Start()
{
// Need to call login in the first scene. only call one time while the game starting
_ = await client.Login("RandomID", "randomSecretKey");


// Try to get player profile
var playerProfile = await client.Send<PlayerProfile>(new GetPlayerObjectCommand("Profile"));
Debug.Log(playerProfile);

// update player name
_ = await client.Send<PlayerProfile>(new PostPlayerObjectCommand<PlayerProfileInput>("Profile", new PlayerProfileInput
{
PlayerName = "David"
}));

}
}

Example

A working example is available here.