0.0.4 • Published 7 months ago

@layerg/layerg-js v0.0.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

LayerG JavaScript client

JavaScript client for LayerG server written in TypeScript. For browser and React Native projects.

LayerG is an open-source server designed to power modern games and apps. Features include user accounts, chat, social, matchmaker, realtime multiplayer, and much more.

This client implements the full API and socket options with the server. It's written in TypeScript with minimal dependencies to be compatible with all modern browsers and React Native.

Full documentation is online - https://docs.layerg.xyz

Getting Started

You'll need to setup the server and database before you can connect with the client. The simplest way is to use Docker but have a look at the server documentation for other options.

  1. Install and run the servers. Follow these instructions.

  2. Import the client into your project. It's available on NPM and can be also be added to a project with Bower or other package managers.

    npm install @layerg/layerg-js

    You'll now see the code in the "node_modules" folder and package listed in your "package.json".

  3. Use the connection credentials to build a client object.

    import {Client} from "@layerg/layerg-js";
    
    var useSSL = false; // Enable if server is run with an SSL certificate.
    var client = new Client("defaultkey", "127.0.0.1", "7350", useSSL);

Usage

The client object has many methods to execute various features in the server or open realtime socket connections with the server.

Authenticate

There's a variety of ways to authenticate and bridge traditional account to Web3 space with the server. Authentication can create a user if they don't already exist with those credentials. It's also easy to authenticate with a social profile from Facebook, Twitter, Google, Telegram, ...

Requests

The client includes lots of builtin APIs for various features of the game server. These can be accessed with the methods which return Promise objects. It can also call custom logic as RPC functions on the server. These can also be executed with a socket object.

All requests are sent with a session object which authorizes the client.

License

This project is licensed under the Apache-2 License.