1.4.3 • Published 1 year ago

arena-rt v1.4.3

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Presence Socket

Features

  • User presence ( online or offline )
  • User typing ( when a user start typing )
  • User reactions on message

Feature flags

The variables will disable or enable some features.

⚠️ These feature should be disable only in emergency situations.

FlagTypeOptionsDescription
DISABLE_LEFT_JOINAWS Parameter'true'/anyWhen true will disable all left/join notifications
DISABLE_REACTIONSAWS Parameter'true'/anyWhen true will accept new accounts using a domain that is alredy used by another account

AWS Parameters

Getting Started

  1. npm install

  2. $ aws configure
       AWS Access Key ID [None]: <your AWS access Key ID>
       AWS Secret Access Key [None]: <your AWS Secret Access Key>
       Default region name [None]: us-west-2
       Default output format [None]: json
  3. export AWS_CONFIG_FILE= ~/.aws/credentials
    export AWS_SDK_LOAD_CONFIG=1
    export REDIS_ENDPOINT=<Redis endpoint hostname>
    export REDIS_PORT=15280
    export REDIS_PASSWORD=<Redis password>
  4. npm run dev

Running locally

Running inside a docker container. docker-compose up realtime

this command will setup the dynamodb tables. After this you can stop the docker-compose and the redis and dynamodb containers will be running.

Running with npm/yarn

yarn start

To run this command you need to have redis and dynamodb running on docker compose, and need to run at least one time docker-compose up dynamodb-setup

Dependencies

  • docker-composer
  • Nodejs 16
  • NPM 6

Setting up Postman Client

  1. Create new WebSocket Request
  2. Socket type: Socket.IO
  3. URL: localhost:3000/?EIO=4&transport=websocket
  4. Settings > Client version: v4
  5. Settings > Handshake request timeout: 20000
  6. Compose message:
    {
        "channelId": "5ecfbf0a9d9da700083cef61",
        "siteId": "5e308d3468fd630008d02305",
        "channelType": "chat_room",
        "user": {
            "isMobile": false,
            "userId": "1234",
            "isAnonymous": false,
            "name": "Lucas Fonseca",
            "image": "https://stationfy.imgix.net/cache/1627916500323-1.jpeg",
            "country": "BR"
        }
    }
  7. Compose message type: JSON
  8. Check checkbox Acknowledgement
  9. Add listeners:
    • presence.info
    • user.joined
    • user.left
    • user.change
    • disconnect

Logging

Use the lib/logger module to register logs. This is a wrapper for pino logger.

const Logger = require('./lib/logger');

const log = Logger('presence-server');

log.debug({ msg: 'proceess.done', obj, value: 10, });
log.info({ msg: 'proceess.done', obj, value: 10, });
log.warn({ msg: 'proceess.done', obj, value: 10, });
log.error({ msg: 'proceess.done', obj, value: 10, });

To enable this logger ( egg: 'presence-server'), export a environment variable as the following:

export DEBUG=arena*presence-server # will enable all log levels for presence-server export DEBUG=arena:info:presence-server # will enable only info level for presence-server