revents
Connect two EventEmitters via a socket.
Installation
npm i revents
Example
In the server.js
file:
const RemoteEventEmitter: Connection = const net = const server = net server
In the client.js
file:
const RemoteEventEmitter = const net = const socket = netconst connection = socket connection connection
API
The RemoteEventEmitter
extends the Connection
class from the socket-json-wrapper package.
This means that you can use the send method and the "message"
event.
emitter.remoteEmit(event, ...args)
- event
<string>
- The name of the event. - ...args
<any>
- Arguments for the event.
Emit an event on the EventEmitter on the other side of the socket connection.
It returns a <boolean>
that is true
if the event was written to the socket.