Skip to content

Instantly share code, notes, and snippets.

@enricop89
enricop89 / query.graphql
Created January 19, 2021 10:20
Insights API Query Example
{
project(projectId: 123456) {
sessionData {
sessions(sessionIds:["YOUR_SESSION_ID"]){
resources {
subscriberMinutes,
publisherMinutes
}
}
}
@enricop89
enricop89 / App.js
Created July 21, 2020 12:45
RN App js file for testing setPreferredRes and FrameRate
import React, { Component } from 'react';
import { View, Button, TextInput, Text, SafeAreaView } from 'react-native';
import { OTSession, OTPublisher, OTSubscriber, OT } from 'opentok-react-native';
import { Picker } from '@react-native-community/picker';
export default class App extends Component {
constructor(props) {
super(props);
this.apiKey = '';
this.sessionId =
@enricop89
enricop89 / index.js
Created June 10, 2020 07:50
getDiplayMedia with audio constraint
let publisher;
const handleError = (e) => console.log(e);
const startScreenShareWithAudio = async () => {
let stream;
try {
stream = await navigator.mediaDevices.getDisplayMedia({video: true, audio: true});
} catch (e) {
handleError(e);
}
if (stream) {
@enricop89
enricop89 / publisher.js
Last active May 22, 2020 08:05
Example of Publisher Retry logic
let currentRetryAttempt = 0;
const maxRetryAttempts = 3;
const retryAttemptTimeout = 1000;
function handleRetryPublisher() {
setTimeout(() => {
currentRetryAttempt += 1;
this.createPublisher();
}, this.retryAttemptTimeout);
}
@enricop89
enricop89 / lambda.yml
Created April 18, 2020 10:38
CF Lambda DLQ example
Resources:
MyFunction:
Type: AWS::Lambda::Function
Properties:
DeadLetterConfig:
TargetArn: arn:aws:sqs:us-east-2:123456789012:dlq
@enricop89
enricop89 / handler.js
Created April 17, 2020 06:51
AWS lambda handler - Global exceptions
module.exports.handler = async (event) => {
console.log('Received event:', JSON.stringify(event, null, 2));
try {
// Function Logic
} catch (err) {
console.log('[Handler] - Main function: ', err);
// Send the error to Third-party monitoring services
}
};
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="nexmoClient.js"></script>
</head>
// First option
application.callServer(JSON.stringify({number: 393201122334, clientRef: "my-reference"}))
// Second option
application.callServer("393201122334_my-ref")
// then split the number in your answer NCCO
@enricop89
enricop89 / nginx.conf
Last active March 31, 2020 14:12
Nginx Proxy Configuration
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
@enricop89
enricop89 / App.js
Created March 23, 2020 08:49
React-native - Example of proxyURL
import React, { Component } from 'react';
import { View } from 'react-native';
import { OTSession, OTPublisher, OTSubscriber } from 'opentok-react-native';
export default class App extends Component {
constructor(props) {
super(props);
this.apiKey = '';
this.sessionId = '';
this.token = '';