Skip to content

Instantly share code, notes, and snippets.

@enricop89
enricop89 / App.js
Created Jul 21, 2020
RN App js file for testing setPreferredRes and FrameRate
View App.js
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 Jun 10, 2020
getDiplayMedia with audio constraint
View index.js
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
Example of Publisher Retry logic
View publisher.js
let currentRetryAttempt = 0;
const maxRetryAttempts = 3;
const retryAttemptTimeout = 1000;
function handleRetryPublisher() {
setTimeout(() => {
currentRetryAttempt += 1;
this.createPublisher();
}, this.retryAttemptTimeout);
}
@enricop89
enricop89 / lambda.yml
Created Apr 18, 2020
CF Lambda DLQ example
View lambda.yml
Resources:
MyFunction:
Type: AWS::Lambda::Function
Properties:
DeadLetterConfig:
TargetArn: arn:aws:sqs:us-east-2:123456789012:dlq
@enricop89
enricop89 / handler.js
Created Apr 17, 2020
AWS lambda handler - Global exceptions
View handler.js
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
}
};
View index.html
<!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>
View example.js
// 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 Mar 31, 2020
Nginx Proxy Configuration
View nginx.conf
# 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 Mar 23, 2020
React-native - Example of proxyURL
View App.js
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 = '';
@enricop89
enricop89 / response.json
Created Mar 5, 2020
Vonage AI - Sample NLU Response
View response.json
"nluResponse": {
"debug": null,
"input": "hi",
"result": {
"action": "welcome",
"intent_on_hold": "",
"completion_attempts": 0,
"contexts": [],
"dialog_complete": true,
"intent": "welcome message",
You can’t perform that action at this time.