This file contains hidden or 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
S3Bucket: | |
Type: AWS::S3::Bucket | |
Properties: | |
BucketName: !Join ['-', [!Ref Stage, !Ref 'AWS::AccountId', 's3bucket']] |
This file contains hidden or 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
ECRRepository: | |
Type: AWS::ECR::Repository | |
Properties: | |
RepositoryName: !Join ['-', [!Ref Stage, !Ref 'AWS::AccountId', 'ecr-repository']] |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>WebRTC Video Chat</title> | |
<style> | |
#videoContainer { |
This file contains hidden or 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 createAndSendAnswer(){ | |
// Create Answer | |
connection.createAnswer().then( | |
answer => { | |
log('Sent The Answer.'); | |
// Set Answer for negotiation | |
connection.setLocalDescription(answer); |
This file contains hidden or 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 createAndSendOffer(){ | |
if(channel){ | |
channel.close(); | |
} | |
// Create Data channel | |
channel = connection.createDataChannel('channel', {}); | |
setChannelEvents(channel); | |
// Create Offer |
This file contains hidden or 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 createRTCPeerConnection(){ | |
connection = new RTCPeerConnection(configuration); | |
// Add both video and audio tracks to the connection | |
for (const track of localStream.getTracks()) { | |
log("Sending Stream.") | |
existingTracks.push(connection.addTrack(track, localStream)); | |
} | |
// This event handles displaying remote video and audio feed from the other peer |
This file contains hidden or 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 connectToWebSocket(){ | |
socket = new WebSocket(webSocketConnection); | |
// Create WebRTC connection only if the socket connection is successful. | |
socket.onopen = function(event) { | |
log('WebSocket Connection Open.'); | |
createRTCPeerConnection(); | |
}; | |
// Handle messages recieved in socket |
This file contains hidden or 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
service: awswebsocketchat | |
frameworkVersion: "1.48.2" | |
custom: | |
currentStage: ${opt:stage, self:provider.stage} | |
lambdaRunTime: python3.7 | |
socketConnectionsTableName: socketConnections-#{AWS::AccountId}-${self:custom.currentStage} | |
provider: | |
name: aws |
This file contains hidden or 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
import json | |
import boto3 | |
import os | |
dynamodb = boto3.client('dynamodb') | |
def handle(event, context): | |
connectionId = event['requestContext']['connectionId'] | |
# Delete connectionId from the database |
This file contains hidden or 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
import json | |
import boto3 | |
import os | |
dynamodb = boto3.client('dynamodb') | |
def handle(event, context): | |
message = json.loads(event['body'])['message'] | |