Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
actionhero-client
Advanced tools
Readme
For one node.js servers talking to another ActionHero server, over the socket protocol.
This library makes it easy for one nodeJS process to talk to a remote actionhero server.
This library makes use of actionhero's TCP socket connections to enable fast, stateful connections. This library also allows for many concurrent and asynchronous requests to be running in parallel by making use of actionhero's message counter.
note: This Library is a server-server communication library, and is NOT the same as the websocket client library that is generated via the actionhero server.
Installation should be as simple as:
npm install --save actionhero-node-client
and then you can include it in your projects with:
var ActionheroNodeClient = require("actionhero-node-client");
var client = new ActionheroNodeClient();
Once you have included the ActionheroClient library within your project, you can connect like this:
await client.connect({
host: "127.0.0.1",
port: "5000",
});
default options (which you can override) are:
var defaults = {
host: "127.0.0.1",
port: "5000",
delimiter: "\r\n",
logLength: 100,
secure: false,
timeout: 5000,
reconnectTimeout: 1000,
reconnectAttempts: 10,
};
One you are connected (by waiting for the "connected" event or using the connect
callback), the following methods will be available to you:
async ActionheroNodeClient.connect()
async ActionheroNodeClient.disconnect()
{error, data, delta} = async ActionheroNodeClient.paramAdd(key, value)
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.paramDelete(key)
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.paramsDelete()
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.paramView(key)
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.paramsView()
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.details()
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.roomView(room)
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.roomAdd(room)
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.roomLeave(room)
data
), a possible error (error
), and the response's duration (delta
){error, data, delta} = async ActionheroNodeClient.say(room, msg)
msg
can be a string or an ObjectActionheroNodeClient.action(action)
paramAdd
data
), a possible error (error
), and the response's duration (delta
)ActionheroNodeClient.actionWithParams(action, param)
{key: "myKey", value: "myValue"}
data
), a possible error (error
), and the response's duration (delta
)ActionheroNodeClient will emit a few types of events (many of which are caught in the example below). Here are the events, and how you might catch them:
client.on("connected")
client.on("end")
client.on("welcome", (welcomeMessage) => {})
client.on("error", (error) => {})
client.on("say", (message) => {})
timeStamp
, room
, from
, and message
client.on("timeout", (error, request, caller) => {})
There are a few data elements you can inspect on actionheroClient
:
ActionheroNodeClient.lastLine
ActionheroNodeClient.userMessages
say
message from all usersActionheroNodeClient.log
ActionheroNodeClient.messageCount
var ActionheroNodeClient = require("actionhero-node-client");
async function main () {
const client = new ActionheroNodeClient()
client.on('say', (message) => {
console.log(' > SAY: ' + message.message + ' | from: ' + message.from)
})
client.on('welcome', (welcome) => {
console.log('WELCOME: ' + welcome)
})
client.on('error', (error) => {
console.log('ERROR: ' + error)
})
client.on('end', () => {
console.log('Connection Ended')
})
client.on('timeout', (request, caller) => {
console.log(request + ' timed out')
})
await client.connect({host: '127.0.0.1', port: '5000'})
// get details about myself
console.log('My Details: ', client.details)
// try an action
const params = { key: 'mykey', value: 'myValue' }
let {error, data, delta} = await client.actionWithParams('cacheTest', params)
if (error) { throw error }
console.log('cacheTest action response: ', data)
console.log(' ~ request duration: ', delta)
// join a chat room and talk
await client.roomAdd('defaultRoom')
await client.say('defaultRoom', 'Hello from the actionheroClient')
await client.roomLeave('defaultRoom')
// leave
await client.disconnect()
console.log('all done!')
}
main()
FAQs
ActionHero client for other node.js servers to use
The npm package actionhero-client receives a total of 3 weekly downloads. As such, actionhero-client popularity was classified as not popular.
We found that actionhero-client 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.