Is it possible to build a function in AWS Lambda that creates a websocket and send data to subscribed applications?
Something like this:
John has the app SuperPh
Yes, you can publish events as a socket.io client to a socket.io server using AWS Lambda.
Steps to implement:
npm install socket.io-client --save in the project folder.index.js. Here is an example:exports.handler = async (event) => {
var io = require('socket.io-client');
var socket = io.connect("http://example.com:9999");
let payload = { "id": "1" };
socket.emit("MyEvent", payload);
return 'Sent message!';
};
Project
node_modulesindex.jsonpackage-lock.jsonpackage.jsonSave and test.