node-red-contrib-viseo-bot-socketio
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -47,3 +47,3 @@ const helper = require('node-red-viseo-helper') | ||
RED.nodes.registerType("socketio-server-config", registerConfig); | ||
RED.nodes.registerType("socketio-server-config", registerConfig); | ||
RED.nodes.registerType("socketio-server", registerNode, { credentials: { secret: {type: "text"}} }); | ||
@@ -80,3 +80,3 @@ } | ||
const bindIOServer = (node, config) => { | ||
const bindIOServer = (node, config) => { | ||
if (!io) { return log("WebSocket server not available..."); } | ||
@@ -87,3 +87,3 @@ | ||
io.on('connection', (socket) => { | ||
io.on('connection', (socket) => { | ||
let client = { "socket" : socket, replies : {} } | ||
@@ -136,11 +136,13 @@ CLIENTS[client.socket.id] = client; | ||
// Set the convId to the socketId | ||
message.socket = client.socket.id | ||
// Bind ClientID to socket's data (if provided) | ||
if (message._client_id){ | ||
client._client_id = message._client_id | ||
message.socket = client._client_id // override the convId with a generic reference | ||
} | ||
message.socket = client.socket.id | ||
let data = botmgr.buildMessageFlow({ "message" : message }, { | ||
userId: 'message._client_id', | ||
userId: 'message._client_id', | ||
convId: 'message.socket', | ||
@@ -151,5 +153,5 @@ payload: 'message.content', | ||
}) | ||
// Handle Prompt | ||
let convId = botmgr.getConvId(data) | ||
let convId = botmgr.getConvId(data); | ||
if (botmgr.hasDelayedCallback(convId, data.message)) return; | ||
@@ -170,3 +172,3 @@ | ||
let namespace = config.namespace || 'assistant'; | ||
try { | ||
@@ -184,6 +186,6 @@ | ||
let client = CLIENTS[socket]; | ||
if (!client){ | ||
if (!client){ | ||
let userId = data.user.id | ||
if (!userId){ return node.warn('Client SocketId ' + socket + ' not found ')} | ||
// Find the first client matching given userID has a fallback | ||
@@ -193,3 +195,6 @@ for (let sock of Object.keys(CLIENTS)){ | ||
if (c._client_id === userId){ | ||
client = c; | ||
client = c; | ||
// node.warn('Override Conversation ID: ' + client.socket.id) | ||
// helper.setByString(data, 'user.address.conversation.id', client.socket.id) | ||
node.warn('Conversation ID custom: ' + botmgr.getConvId(data)) | ||
break; | ||
@@ -199,3 +204,3 @@ } | ||
if (!client){ | ||
if (!client){ | ||
node.warn('Client SocketId ' + socket + ' not found for userId '+ userId) | ||
@@ -207,3 +212,3 @@ return; | ||
// Store a replyId x data to a given Socket | ||
// and wait client acknowledge message | ||
// and wait client acknowledge message | ||
// to call: helper.fireAsyncCallback(data); | ||
@@ -248,2 +253,2 @@ let replyId = uuidv4(); | ||
return replies[0]; | ||
} | ||
} |
{ | ||
"name" : "node-red-contrib-viseo-bot-socketio", | ||
"version" : "0.2.0", | ||
"version" : "0.2.1", | ||
"description" : "VISEO Bot Maker - SocketIO channel connector", | ||
@@ -5,0 +5,0 @@ "dependencies" : { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19140
193
0