1 // eslint-disable-next-line n/no-unpublished-require
2 const RoboHydra = require('robohydra');
3 const RoboHydraHead = RoboHydra.heads.RoboHydraHead;
4 const RoboHydraWebSocketHead = RoboHydra.heads.RoboHydraWebSocketHead;
5 const RoboHydraWebSocketHeadProxy = RoboHydra.heads.RoboHydraWebSocketHeadProxy;
7 // eslint-disable-next-line no-unused-vars
8 exports.getBodyParts = function (conf) {
16 handler: function (req, res) {
17 const msg = JSON.stringify(req.body);
20 res.send('Message sent');
22 res.send('Cannot send message, no opened websocket found');
31 handler: function (req, res) {
34 res.send('Websocket closed');
36 res.send('Cannot close websocket, no opened websocket found');
41 new RoboHydraWebSocketHeadProxy({
44 proxyTo: 'ws://server.example.com',
45 preProcessor: function (data) {
46 console.info(`From the client: ${data}`);
48 postProcessor: function (data) {
49 console.info(`From the server: ${data}`);
53 new RoboHydraWebSocketHead({
56 handler: function (req, socket) {