pubnub / chat-engine-server

ChatEngine REST API as a PubNub Function

Home Page:http://www.pubnub.com/developers/chat-resource-center/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ChatEngine Framework Server

This repository contains the REST API running as a PubNub function that is required for the ChatEngine Framework to operate.

Documentation You can find the full docs on the documentation website.

Provisioning the ChatEngine Framework Application and Key

To set up PubNub to host the ChatEngine Framework REST API on a PubNub Function, you must first set up a new PubNub App. The following outlines how to manually set up a PubNub ChatEngine Framework Application and Key.

  1. Navigate to PubNub's Portal, sign in, and select Create New App.
  2. Enter an App name (e.g. ChatEngine Application) and click Create.
  3. Select the newly made App icon and navigate to the Demo Keyset.
  4. Update the following setting on the keyset:
Presence on
Announce Max 20
Interval 10
Presence Deltas Disabled
Generate Leave on TCP FIN or FIN Disabled
Global Here Now Enabled
Debounce 2
Callback State Change https://pubsub.pubnub.com/v1/blocks/sub-key/
__SUB_KEY__/chat-engine-server?route=user_state
Storage & Playback on
Retention 7 days
Stream Controllers on
Enable Wildcard Subscribe Enabled
PubNub Functions Enabled
Access Manager Enabled

Provisioning the ChatEngine Framework Function

Bundle the server Server Code

The REST API is composed of several files to improve understandability. The files must be bundled into a single function to upload to PubNub.

  1. Clone the chat-engine-server repo and run npm install.
  2. Run npm run build to create a bundled function at build/server.js.
  3. Run npm test to verify that the bundle is correct.
  4. Copy the code to your clipboard for later use.

Create a PubNub REST Function

  1. On your PubNub Admin Dashboard, go the ChatEngine app key you set up in the previous section to upload your Function.

  2. Select the Functions tab on the top left side of the page.

  3. Fill out the following text fields and click Create New Module:

    Field Value
    Module Name: ChatEngine Server
    Module Description: REST Function that powers PubNub ChatEngine
  4. Within the ChatEngine Module, click create and fill in the following text fields:

    Field Value
    Function Name ChatEngine Server
    Select Event Type On Request
    URI path chat-engine-server
  5. Click Create Function to navigate to the PubNub Functions Console.

  6. With the console open, copy and paste the server code from build/server.js into the console editor and click Save.

  7. Click Save at the top left side of the console editor.

  8. Click My Secrets, and enter the following, (get the secretKey from the App and Key page):

    Field Value
    Enter Key secretKey
    Enter Value __COPY_AND_PASTE_PUBNUB_SECRET_KEY__
  9. Click Save.

  10. Returning to the console, click Start Function and you are done.

Building Chat Applications with PubNub

For more information on build chat applications with PubNub, see our Chat Resource Center.

About

ChatEngine REST API as a PubNub Function

http://www.pubnub.com/developers/chat-resource-center/

License:Other


Languages

Language:JavaScript 98.4%Language:Shell 1.6%