
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@amazebot/rocket-socket
Advanced tools
Communicate with Rocket.Chat Realtime API via websocket (DDP).
Communicate with Rocket.Chat Realtime API via websocket (DDP).
See the main rocket-control README for general configuration.
This example script uses rocket-socket and rocket-sims to create
a new bot user, connect to the general channel and stream all bot mentions to
the console.
new Socket()Accepts options object, or uses defaults from environment config. Attributes can
include host string and ssl boolean.
Creates a websocket handler instance to manage the connection with Rocket.Chat.
import { Socket } from '@amazebot/rocket-socket'
const socket = new Socket()
.open() and .close()Opens connection with Rocket.Chat. Returns promise.
Accepts option number of ms to attempt re-opening.
const socket = new Socket()
await socket.open()
await socket.close()
.login(credentials) and .logout()Login can be called without explicit .open(), it will open the socket to login.
Login can be called without credentials to use the default user/pass from environment configs.
Login returns a credential object that can be used to resume login after closing and re-opening socket.
Login accepts a range of credential objects (including the resume object mentioned above):
Username/password:
{
username: string
password: string
}
Server credentials:
{
user: { username: string }
password: { digest: string, algorithm: string }
}
Oauth token:
{
oauth: {
credentialToken: string
credentialSecret: string
}
}
Resume token:
{
resume: string
}
.connected and .loggedInBoolean attributes for confirming connection status.
.subscribe(name, params, callback)Subscribe to any stream of events on the server, passing the stream name and params array as per Realtime API docs here: https://rocket.chat/docs/developer-guides/realtime-api/subscriptions/
The callback function will be called with every emitted event.
Subscribe method returns a subscription object, with the same attributes used to create it, along with an .id and .unsubscribe() method.
Method calls can also be made over DDP manually through the CLI, using a method name and optional other parameters. Results will be printed to console. Requires the same config as above, with username/password as ENV or command line opts.
ts-nodeRun pre-compiled locally, using
> ts-node src/cli --method getServerInfo
Outputs
{ result:
{ version: '0.73.2',
...
You can also pass params
> ts-node src/cli --method getRoomNameById --params GENERAL
Outputs
{ result: 'general' }
rocket-callRun the compiled bin when installed as a dependency
> node_modules/bin/rocket-call --method getServerInfo
Or use the alias arguments for both method and params
> node_modules/bin/rocket-call -m getRoomNameById -p GENERAL
Could work as a global NPM package too.
FAQs
Communicate with Rocket.Chat Realtime API via websocket (DDP).
The npm package @amazebot/rocket-socket receives a total of 3 weekly downloads. As such, @amazebot/rocket-socket popularity was classified as not popular.
We found that @amazebot/rocket-socket demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.