Skip to content

Instantly share code, notes, and snippets.

View irbisadm's full-sized avatar

Igor Sheko irbisadm

  • Yerevan, Armenia
View GitHub Profile
// bind primary callbacks
function bindCallCallbacks(e){
logger.write(`[WebSDk] Set up listeners for ID: ${currentCall.id()}`);
currentCall.on(VoxImplant.CallEvents.Connected,onCallConnected);
currentCall.on(VoxImplant.CallEvents.Disconnected,onCallDisconnected);
currentCall.on(VoxImplant.CallEvents.Failed,onCallFailed);
callForm.style.display = 'none';
callDisconnect.style.display = 'block';
}
sdk.on(VoxImplant.Events.IncomingCall, function (e) {
logger.write(`[WebSDk] New incoming call with ID: ${e.call.id()}`);
// if call already exists – hangup
if(currentCall){
logger.write('[WebSDk] You already have active call. Hangup.');
e.call.hangup();
}else{
currentCall = e.call;
bindCallCallbacks();
currentCall.answer();
// link to current active call
let currentCall;
// create new call
callForm.addEventListener('submit', function (e) {
e.preventDefault();
const formData = new FormData(e.target);
currentCall = sdk.call({number: formData.get('number'), video: {sendVideo: true, receiveVideo: true}});
bindCallCallbacks();
});
try {
// logging in
await sdk.login(formData.get('login'), formData.get('password'));
logger.write('[WebSDk] Authorization completed');
// change form visibility
loginForm.style.display = 'none';
callForm.style.display = 'block';
}catch (e) {
logger.write('[WebSDk] Wrong login or password');
}
// we must check current SDK state to prevent an exception in case of repeated init and connect
if(sdk.getClientState()!=='CONNECTED') {
// init SDK
await sdk.init({remoteVideoContainerId:'js__workbench'});
logger.write('[WebSDk] Initialization completed');
// connecting to the Voximplant Cloud;
// "false" argument disables checking of UDP connection (for fastest connect)
await sdk.connect(false);
logger.write('[WebSDk] Connected');
}
// set EventListener for the form submission;
// we can send form to server by pressing the Enter key or the "Connect&Login" button
loginForm.addEventListener('submit', async function (e) {
e.preventDefault();
const formData = new FormData(e.target);
});
const sdk = VoxImplant.getInstance();
'use strict';
// logger in the right column
const logger = new cLogger(document.querySelector('.js__logarea'));
const loginForm = document.querySelector('.js__login-form');
const callForm = document.querySelector('.js__call-form');
const callDisconnect = document.querySelector('.js__call-disconnect');
// disable calling form until login
<script type="text/javascript" src="//cdn.voximplant.com/edge/voximplant.js"></script>
<script>
const sdk = VoxImplant.getInstance();
sdk.init(VOXIMPLANT_API_OPTIONS)
.then(()=>sdk.connect())
.then(()=>sdk.login('foo@bar.baz.voximplant.com', 'secretpass'))
.then((result)=>{
sdk.setVideoSettings(VOXIMPLANT_VIDEO_SETTINGS);
sdk.setVideoBandwidth(VOXIMPLANT_VIDEO_BANDWIDTH);
console.log(result);
@irbisadm
irbisadm / anet_a6.def.json
Created February 17, 2017 13:56 — forked from maciekish/Anet+A6_settings.inst.cfg
Anet A6 profile for Cura 2.3. Save in "Cura 2.3\resources\definitions" and restart Cura
{
"id": "anet_a6",
"version": 2,
"name": "Anet A6",
"inherits": "fdmprinter",
"metadata": {
"visible": true,
"author": "Maciej Swic",
"manufacturer": "Anet",
"category": "Anet",