Commit 65043852 authored by Yoann HOUPERT's avatar Yoann HOUPERT

first step to socket.io integration

parent 33334800
Pipeline #13903 failed with stage
......@@ -90,24 +90,6 @@ robot = {
}
},
openSTTSocket(easyrtcid) {
const ws = robotLib.stt.getTranscriptSocket(e => {
console.log('> ' + e.text);
robotLib.reco.send(
{
from: robot.room,
text: e.from + '\t' + e.until + '\t' + easyrtcid + '\t' + e.text
});
});
ws.addEventListener('error', e => {
// Try to open new connection on error
console.error('STT ws for ' + easyrtcid + ' error. Trying to reopen');
console.error(e);
robot.openSTTSocket(easyrtcid);
});
robot.recordedParticipantsWS[easyrtcid] = ws;
},
getUserStream(easyrtcid) {
robotController.getRemoteStream(easyrtcid).then(stream => {
if (stream !== undefined) {
......@@ -116,13 +98,13 @@ robot = {
});
},
audioGenerator(easyrtcid, e) {
robot.recordedParticipantsWS[easyrtcid].send(e.data);
audioGenerator(easyrtcid, audio) {
robot.socket.emit('audio_from_' + easyrtcid, audio.data)
},
recordParticipant(easyrtcid) {
robot.openSTTSocket(easyrtcid);
robot.socket.emit('new_user', easyrtcid);
robot.getUserStream(easyrtcid);
},
......@@ -162,8 +144,21 @@ robot = {
start: (room, clientConfig) => {
robot.room = room;
robot.clientConfig = clientConfig;
robotLib.stt = robotLib.stt(robot.clientConfig);
robot.socket = io.connect(robot.clientConfig.gstreamerURL, {
transports: ['websocket']
})
robot.socket.on('connect', () => {
console.log("Connected over websockets to proxy")
})
robot.socket.on('connect_error', (error) => {
console.log(error)
})
robot.socket.on('error', (e) => {
console.log(e)
})
robot.socket.on('resume_data', (data) => {
//send data to hublin
})
robotLib.reco = robotLib.reco(robot.clientConfig);
robotLib.archive = robotLib.archive(robot.clientConfig);
......@@ -196,7 +191,7 @@ robot = {
setInterval(() => robotLib.reco.getOnlineReco(robot.room)
.then(robot.processReco)
.catch(console.error),
8000));
8000));
// Record current participants already present in the room
// (except the robot itself)
......
......@@ -24,10 +24,11 @@
"name": "hublot",
"avatar": "data:image/png;base64,iVBORw0KGg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tpCK8mS9RUgynV5NYtvMnMK9Am2eUFAt93c1bLVoKnIrKUw3LdiYi9CqA94CX9XC+BthdIruPA/txSxl3FDE4hNGYYdnOaeCyJKzMqmET+CXhkFOnTeCnhENO/WgCJxMOOTViAscTDjn1lQn0JxxyzgaOmjpKHk1wZNQp+C/DubcMDZjBrdgNM52Z0MfOlKGdfeBmOAHeL0MDmpUUrbhbPtpwc9N9+p55AvgU2ICbfW3Rx15Yhna+C75kl2U7I0B7TD++RUmxLWCuFmau1wtsjamdJ5UU1/m7HsCbMV6lKf9kOQ9IoOvEY9JO742R1pBUXC1QUhSUuo2xjTNKitkkYHr+uhd4NY5WWLbzNzAIbMbdgzeppJhJO8bQk95lwOvEW470ov+foIq7GeKvaJkGfgf+0l0rpQHNxU0sNsTcnnElRYv/g6AG9JQhXJgDLNSvStDD6R8YGbrFIHB7nQaYh5UU3TlB6ZGlEfinTkGZQCp9JM5WPi2BQ3UGabmSYigTvUzDt01a1VmNqzcTJAi3aegA7u7yWtZeJUVPrv6YNRJWUqwCvqxhSP1Kip5ce/fy2YZ2DLirxiAdUVJ0Fr0NLQDWx8CDtUJJSWGEnZCbIQ16sB4CttQIp3fymZCbedD3/m4D7sBd0KxmjeUbXBXisoO4D535rIpBLY4clG/i2AV04z6Rp9qU1xJ8SbIElu2YuGnbN4i2jqHUeklJsT02UD5gjbhFYr0VlAnIpUXAaEnCgwKhdQHrgU7gggoG9SvuAsZ0NlhmhA0YUFKsBFpwH7K1R480lTZaXgqMkOMhPLFkMtMen9QO3AhcjVuRvAR39Wc+7nJUObwvBZwF7s703JZ/AccI0dMbvIyTAAAAAElFTkSuQmCC",
"proxified": true,
"gstreamerURL": "ws://localhost:3001/kaldi",
"gstreamerURL": "http://localhost:3001",
"externalLibs": [
"https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.4/sockjs.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"
"https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.0/socket.io.js"
],
"archive": "http://localhost:8080/api/summary",
"reco": {
......@@ -43,7 +44,7 @@
"reco": {
"host": "hublot_recommender_1",
"port": 8080,
"reconnectInterval": 5000
"reconnectInterval": 50000
},
"kaldi": "ws://hublot_kaldi-gstreamer_1:80/client/ws/speech?content-type=audio/x-matroska,+rate=(int)48000,+channels=(int)"
}
......
......@@ -127,7 +127,7 @@ module.exports = config => {
}
} else {
console.error('Online reco: error trying to reach http://%s:%s/resources',
config.services.reco.host, config.services.reco.port);
config.services.reco.host, config.services.reco.port);
}
connectionToClient.close();
}
......@@ -147,21 +147,38 @@ module.exports = config => {
return {
create: (resume) => {
resume.createFolder()
const server = http.createServer();
const stompClient = createStompClient();
const io = require('socket.io')(server, {
transports: ['websocket']
});
io.sockets.on('connection', (socket) => {
// let asd = {} //port 8881 - connexion de contrôle ASD
console.log("NEW CONNEXION !")
socket.on('new_user', (userId) => {
//create ASD stream //port 8882 - connexion de data
let vad = userId
//asd.on("resume_data", soket.emit('resume_data'))
//register custom event for user
socket.on('audio_from_' + userId, (data) => {
console.log("DATA RECEIVED FOR USER : ",vad)
//console.log(data)
//asd.send(data)
})
})
});
/*
const wssServer = new WebSocket.Server({
server,
autoAcceptConnections: true
});
wssServer.on('connection', (connectionToClient, req) => {
if (req.url === '/kaldi') {
kaldiWS(connectionToClient, resume);
return;
}
if (req.url === '/chat') {
recoChatWS(connectionToClient, stompClient);
return;
......@@ -176,10 +193,11 @@ module.exports = config => {
}
console.error('proxy: unknown path for ws connection', req.url);
});
*/
server.listen(config.port);
console.log('Proxy listening on port', config.port);
}
};
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment