1.0.4 • Published 3 years ago

pc.nakama v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

pc.nakama

A heroic labs - nakama js wrapper for playcanvas game engine.

First Steps

you don't need to import the nakama-js.umd.js file, this wrapper uses the 2.1.5 version inside

variables:

  • server_ip : your nakama server ip

  • nakama_port : your nakama server port (by default is 443 when using SSL connection)

  • useSSL : this is a bool, use true if your server uses HTTPS.

This nakama wrapper uses only custom authentication, other auth methods will be supported in further updates.

  • customId : the user's customId

  • clientUsername : the user's username

This wrapper executes this options automaticaly:

  • Auto-import of the nakama.js client
  • Creates the client
  • CheckSession and Authenticate your users
  • Establish the socket connection
  • Retrieve and Update the oponents list without process the match-presence events.

For more information about Custom Authentication see the documentation

Use the playcanvas.js engine-only solution

Import the library like any ES6 module in your html file.

<script type="module">
        import NakamaJs from "./pc-nakama.js";
        var nakama = new NakamaJs(<server_ip>, <nakama_port>,<useSSL>, <customId>, <clientUsername>);
</script>

Use inside playcanvas editor script:

  1. Import the file in the editor, don't drop the file into the editor the drop option doesn't load well the file, instead use the 'upload' option.

  2. uncheck the 'preload' option in the file editor options.

  3. you can create an empty script, attach the script as the first in the 'script loading order', don't attach it to a component or entity

var module;

(function() {
    var asset = pc.Application.getApplication().assets.find('pc-nakama.min.js');
    
    async function load() {
        module = await import(asset.getFileUrl());
        var nakama = new NakamaJs(<server_ip>, <nakama_port>,<useSSL>, <customId>, <clientUsername>);
    }
    
    load();
})();
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago