1 const RoboHydraHead
= require('robohydra').heads
.RoboHydraHead
;
2 const RoboHydraWebSocketHead
= require('robohydra').heads
.RoboHydraWebSocketHead
;
3 const RoboHydraWebSocketHeadProxy
= require('robohydra').heads
.RoboHydraWebSocketHeadProxy
;
5 exports
.getBodyParts = function(conf
) {
13 handler: function(req
, res
) {
14 const msg
= JSON
.stringify(req
.body
);
17 res
.send('Message sent');
19 res
.send('Cannot send message, no opened websocket found');
28 handler: function(req
, res
) {
31 res
.send('Websocket closed');
33 res
.send('Cannot close websocket, no opened websocket found');
38 new RoboHydraWebSocketHeadProxy({
41 proxyTo
: 'ws://server.example.com',
42 preProcessor: function(data
) {
43 console
.log('From the client: ' + data
);
45 postProcessor: function(data
) {
46 console
.log('From the server: ' + data
);
50 new RoboHydraWebSocketHead({
53 handler: function(req
, socket
) {