This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var server = app.listen(process.env.PORT || 8082, function () { | |
var host = server.address().address | |
var port = server.address().port | |
console.log("PSTN app listening at %s:%s Port", host, port) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
var bodyParser = require('body-parser'); | |
const puppeteer = require('puppeteer'); | |
var urlencodedParser = bodyParser.urlencoded({ extended: true }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//When a stream is added to a channel | |
client.on('stream-added', function (evt) { | |
client.subscribe(evt.stream, handleFail); | |
}); | |
//When you subscribe to a stream | |
client.on('stream-subscribed', function (evt) { | |
let stream = evt.stream; | |
addVideoStream(stream.getId()); | |
stream.play('remote-container'); | |
addCanvas(stream.getId()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The client joins the channel | |
client.join(null,"test",null, (uid)=>{ | |
// Stream object associated with your web cam is initialized | |
let localStream = AgoraRTC.createStream({ | |
streamID: uid, | |
audio: true, | |
video: true, | |
screen: false | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Client Setup | |
// Defines a client for RTC | |
let client = AgoraRTC.createClient({ | |
mode: 'live', | |
codec: "h264" | |
}); | |
// Client Setup | |
// Defines a client for Real Time Communication | |
client.init("82ed46ddc986446a97ead5c10d1c23ee",() => console.log("AgoraRTC client initialized") ,handleFail); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//leave channel | |
leavebtn.addEventListener("click",()=>{ | |
channel.leave(); | |
flag = false; | |
}) | |
}) | |
//logout | |
outbtn.addEventListener("click",()=>{ | |
client.logout().then(()=> {console.log("Client logged out.")}).catch(()=> {console.log("log out failed")}); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//send messages | |
sendbtn.addEventListener("click", ()=>{ | |
channel.sendMessage({ text: msg.value }).then(() => { | |
/* Your code for handling events, such as a channel message-send success. */ | |
chatbox.innerHTML += "<div class='message_holder'><span class='chat user1'>"+ msg.value + "</span></div>"; | |
console.log("Successfully sent message!"); | |
}).catch(error => { | |
/* Your code for handling events, such as a channel message-send failure. */ | |
console.log("Error sending message!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joinbtn.addEventListener("click", ()=>{ | |
//join a channel | |
const channel = client.createChannel(chid.value); //pass your channel ID | |
channel.join().then(() => { | |
/* Your code for handling the event of a join-channel success. */ | |
console.log('Channel joined!'); | |
}).catch(error => { | |
/* Your code for handling the event of a join-channel failure. */ | |
console.log('Channel join failed.'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logger() | |
{ | |
//initialize client | |
const client = AgoraRTM.createInstance(appid.value); | |
//check connection state | |
client.on('ConnectionStateChange', (newState, reason) => { | |
console.log('on connection state changed to ' + newState + ' reason: ' + reason); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = AgoraRTC.createClient(config); | |
function myfunction(){ | |
let handlefail = function(err){ | |
console.log("Error: ", err); | |
}; | |
let remotecontainer = document.getElementById("remote1"); | |
let remote_container = document.getElementById("remote2"); | |
let appid = document.getElementById("appid"); |