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
var http = require('http'); | |
var Static = require('node-static'); | |
var WebSocketServer = new require('ws'); | |
// list of users | |
var CLIENTS=[]; | |
var id; | |
// web server is using 8081 port | |
var webSocketServer = new WebSocketServer.Server({ port: 8081 }); |
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
// client side code | |
var socket = io.connect('http://localhost:3000/'); | |
var chatInfra = io.connect('http://localhost:3000/chat_infra'), | |
chatCom = io.connect('http://localhost:3000/chat_com'); | |
chatInfra.on('name_set', function (data) { | |
chatInfra.on("user_entered", function (user) { | |
$('#messages').append('<div class="systemMessage">' + user.name + ' has joined the room.' + '</div>'); | |
}); |
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
// Set up connection between users. | |
var name, connectedUser; | |
var connection = new WebSocket('ws://127.0.0.1:8081'); | |
connection.onopen = function () { | |
console.log("Connected"); | |
}; | |
// Handle all messages through this callback | |
connection.onmessage = function (message) { |
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"> | |
<title>Creating RTCPeerConnection</title> | |
<style> | |
body { | |
background-color: #3D6DF2; | |
margin-top: 15px; | |
} |
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
{ | |
"countries": [ | |
{ | |
"code": "+7 840", | |
"name": "Abkhazia" | |
}, | |
{ | |
"code": "+93", | |
"name": "Afghanistan" | |
}, |
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
[ | |
{"name": "Afghanistan", "code": "AF"}, | |
{"name": "Aland Islands", "code": "AX"}, | |
{"name": "Albania", "code": "AL"}, | |
{"name": "Algeria", "code": "DZ"}, | |
{"name": "American Samoa", "code": "AS"}, | |
{"name": "Andorra", "code": "AD"}, | |
{"name": "Angola", "code": "AO"}, | |
{"name": "Anguilla", "code": "AI"}, | |
{"name": "Antarctica", "code": "AQ"}, |