Setting up skeleton to start implementing webrtc at the client level
This commit is contained in:
23
freechat-client/src/js/rtc.js
Normal file
23
freechat-client/src/js/rtc.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// Module handles dealing with all the rtc bs that we need to deal with when
|
||||
// doing rtc things
|
||||
// http2 once auth becomes a thing -> save on them tls handshakes
|
||||
const http = require('http')
|
||||
const io = require('socket.io-client')
|
||||
|
||||
|
||||
var room_id;
|
||||
var local_stream;
|
||||
var remote_stream; // cat streams later(?)
|
||||
var rtc_conn;
|
||||
const iceServers = {
|
||||
'iceServers': [
|
||||
{ 'urls': 'stun:stun.services.mozilla.com'},
|
||||
{ 'urls': 'stun:stun.l.google.com:19302'}
|
||||
]
|
||||
}
|
||||
|
||||
// don't really care about video streams
|
||||
var stream_constraints = { audio: true, video : false }
|
||||
|
||||
var is_caller;
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// Dank welcome
|
||||
const fs = require('fs');
|
||||
const homedir = require('os').homedir();
|
||||
const config_path = homedir + '/.config/freechat-client/config.json';
|
||||
|
||||
function create_config() {
|
||||
let default_config = JSON.stringify({
|
||||
'username':null
|
||||
});
|
||||
fs.writeFile(config_path, default_config, function(err) {
|
||||
if(err) {
|
||||
console.log('Unable to create config\nERR: ' + err);
|
||||
}
|
||||
else {
|
||||
console.log('config created');
|
||||
return default_config;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function welcome_msg(username) {
|
||||
console.log('welcome message');
|
||||
let d = document.getElementById('welcome');
|
||||
d.text('Welcome ' + username);
|
||||
}
|
||||
|
||||
function get_config() {
|
||||
try {
|
||||
let raw = fs.readFileSync(config_path);
|
||||
return JSON.parse(raw);
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
let config = get_config();
|
||||
if(!config) {
|
||||
config = create_config();
|
||||
}
|
||||
|
||||
if(config['username'] === null){
|
||||
console.log('no user name setup yet');
|
||||
}
|
||||
else {
|
||||
welcome_msg(config['username']);
|
||||
}
|
||||
@@ -6,9 +6,12 @@
|
||||
<link rel="stylesheet" href="../css/welcome.css"/>
|
||||
<title>Freechat</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="center">Freechat login</h1>
|
||||
<h2 class="center" id="welcome"></h2>
|
||||
<script src="../js/welcome.js"></script>
|
||||
</body>
|
||||
<body>
|
||||
<!-- For sake of argument we'll keep a list of connected clients in the DOM for now -->
|
||||
<div>
|
||||
<h1>User list</h1>
|
||||
<div id="user-list"></div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="../js/rtc.js"></script>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user