arena-rt v1.4.3
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.
Flag | Type | Options | Description |
---|---|---|---|
DISABLE_LEFT_JOIN | AWS Parameter | 'true'/any | When true will disable all left/join notifications |
DISABLE_REACTIONS | AWS Parameter | 'true'/any | When true will accept new accounts using a domain that is alredy used by another account |
Getting Started
npm install
$ 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
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>
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
- Create new
WebSocket Request
- Socket type:
Socket.IO
- URL:
localhost:3000/?EIO=4&transport=websocket
- Settings > Client version:
v4
- Settings > Handshake request timeout:
20000
- 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" } }
- Compose message type:
JSON
- Check checkbox
Acknowledgement
- 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
1 year ago