New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rt-tcp-utils

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rt-tcp-utils

JavaScript utilities for communicating with a C++ real-time application over TCP

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
0
Created
Source

rt-tcp-utils

Utilities for communicating between a JavaScript application and a C++ real-time application created with DevOps Model RealTime or DevOps Code RealTime.

Feel free to extend tcp-server.js to cover your needs. Pull requests are welcome!

Usage

Assuming that the real-time application you want to communicate with runs on localhost on port 9911 you define a TCP server like this:

const tcpServer = require('./tcp-server')('localhost', 9911);

To also be able to receive events sent by the application register a callback function and start listen to events on a port (2234 is the default but can of course be replaced):

tcpServer.setEventReceivedCallback(msgReceived);
tcpServer.startListenForEvents(2234) // Receive TCP requests from RT app on port 2234
.then((data) => {
    console.log("Ready to receive TCP requests");    
});

The callback function msgReceived will be called whenever the real-time application sends out an event. It has an object as argument that contains properties according to the TCPServer documentation. For example:

if (msg.port == "trafficLight") {
	if (msg.event == "red") {
		// Event "red" received on the "trafficLight" port
		// ...
	}
}

To send an event call a function on the tcpServer object. For example:

tcpServer.sendEvent('pedestrian', 'trafficLight'); // Send event "pedestrian" on the "trafficLight" port

Example

This Code RealTime application uses rt-tcp-utils.

Keywords

model-rt

FAQs

Package last updated on 15 Oct 2024

Did you know?

Socket

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.

Install

Related posts