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
navigator.getUserMedia({ video: true, audio: true }, function(stream) { | |
currentUser.stream = stream; | |
}, function() {}); | |
// ... | |
peer = new SimplePeer({ stream: currentUser.stream }); | |
peer.on('stream', function(stream) { | |
var video = document.querySelector("video"); |
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 peer = new SimplePeer({ initiator: true }); | |
peer.on('signal', function (data) { | |
channel.trigger('client-signal-' + peerUserId, { userId: currentUser.id, data: data }); | |
}); | |
peer.on('ready', function () { | |
peer.send('hey peer, how is it going?') | |
}); |
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 peer1 = new SimplePeer({ initiator: true }); | |
var peer2 = new SimplePeer(); | |
peer1.on('signal', function (data) { | |
// when peer1 has signaling data, give it to peer2 | |
peer2.signal(data); | |
}); | |
peer2.on('signal', function (data) { | |
// same as above, but in reverse |
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
class PusherController < ApplicationController | |
protect_from_forgery except: :auth | |
def auth | |
response = Pusher[params[:channel_name]].authenticate params[:socket_id], | |
user_id: params[:id], | |
user_info: { name: params[:name] } | |
render json: response | |
end |
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
<!DOCTYPE html> | |
<html> | |
<head><title>getUserMedia</title></head> | |
<body> | |
<video autoplay></video> | |
<script> | |
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; | |
var constraints = { audio: false, video: 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
app.directive('isolated', function() { | |
return { | |
scope: { | |
message: '=' | |
}, | |
template: '<input ng-model="message.content"><span>{{message.content}}</span>' | |
}; | |
}); |
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
app.directive('isolated', function() { | |
return { | |
scope: {}, | |
template: '<input ng-model="message.content"><span>{{message.content}}</span>' | |
}; | |
}); |
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
<div ng-controller="EditController"> | |
<span>{{message.content}}</span> | |
<div ng-if="userIsAdmin"> | |
<span>Edit Message</span> | |
<input ng-model="message.content"/> | |
</div> | |
</div> |
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
app.controller('OuterController', function($scope) { | |
$scope.outer = 'From the outside'; | |
}); | |
app.controller('InnerController', function($scope) { | |
$scope.inner = 'looking in.'; | |
}); |
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
app.controller('HelloController', function($scope) { | |
$scope.message = 'Hello World!'; | |
}); | |
app.controller('GoodbyeController', function($scope) { | |
$scope.message = 'Goodbye World!'; | |
}); |