nodejs-webrtcsignalexchange.../client/test-client.js

35 lines
854 B
JavaScript
Raw Normal View History

2019-01-19 09:53:09 +00:00
/**
* Node Signal Exchanger test client
*
* @author Pierre HUBERT
*/
const Config = {
port: 8081,
server_name: "localhost",
2019-01-19 12:10:28 +00:00
clientID: location.href.toString().includes("#1") ? "client-1" : "client-2",
otherPeerID: location.href.toString().includes("#1") ? "client-2" : "client-1"
2019-01-19 09:53:09 +00:00
};
let client = new SignalExchangerClient(
Config.server_name,
Config.port,
Config.clientID
);
client.onConnected = function(){
console.log("Connected to signal exchanger server.");
2019-01-19 12:10:28 +00:00
client.sendSignal(
Config.otherPeerID,
"A signal content from " + Config.clientID + " to " + Config.otherPeerID,
);
2019-01-19 09:53:09 +00:00
}
client.onError = function() {
console.error("An error occurred with the connection to the signal exchanger server");
}
client.onClosed = function() {
console.log("Connection to server closed.");
}