|
|
|
@ -31,7 +31,7 @@ var audioTrack;
|
|
|
|
|
var shownPTTHelp = false; |
|
|
|
|
var muteOnMouseUp = true; |
|
|
|
|
|
|
|
|
|
var userListStatus = ''; |
|
|
|
|
var userListStatus = 'Loading...'; |
|
|
|
|
|
|
|
|
|
var MessageBinary = 2; |
|
|
|
|
var MessagePing = 100; |
|
|
|
@ -123,7 +123,13 @@ $(document).ready(function () {
|
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$("#inputheader, #inputcontainer, #inputfooter").on("click", function (e) { |
|
|
|
|
$("#inputheader, #inputfooter").on("click touchstart", function (e) { |
|
|
|
|
$("#chatinput").focus(); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$("#chatinput").on("touchstart", function (e) { |
|
|
|
|
$("#chatinput").focus(); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
@ -149,7 +155,7 @@ $(document).ready(function () {
|
|
|
|
|
$('#voiceactiveright').css('display', 'none'); |
|
|
|
|
$('#voiceButton').html('Join voice chat'); |
|
|
|
|
|
|
|
|
|
updateVoiceStatus(); |
|
|
|
|
updateUserStatus(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
window.setInterval(() => { |
|
|
|
@ -233,7 +239,7 @@ function createPeerConnection(id) {
|
|
|
|
|
if (id == 0 && !shownPTTHelp) { |
|
|
|
|
shownPTTHelp = true; |
|
|
|
|
|
|
|
|
|
Log("* Note: Push-to-talk is bound to <F8>"); |
|
|
|
|
Log("Note: Push-to-talk is bound to <F8>"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('#voicepttcontainer').css('display', 'table-row'); |
|
|
|
@ -243,7 +249,7 @@ function createPeerConnection(id) {
|
|
|
|
|
$('#voiceactiveright').css('display', 'inline-block'); |
|
|
|
|
$('#voiceButton').html('Quit voice chat'); |
|
|
|
|
|
|
|
|
|
updateVoiceStatus(); |
|
|
|
|
updateUserStatus(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (id == 0) { |
|
|
|
@ -302,7 +308,10 @@ function Connect() {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Log("* Connecting..."); |
|
|
|
|
userListStatus = 'Connecting...'; |
|
|
|
|
updateUserStatus(); |
|
|
|
|
|
|
|
|
|
Log("Connecting..."); |
|
|
|
|
|
|
|
|
|
var loc = window.location, wsurl, pathname; |
|
|
|
|
if (loc.protocol === "https:") { |
|
|
|
@ -319,7 +328,7 @@ function Connect() {
|
|
|
|
|
|
|
|
|
|
socket = new WebSocket(wsurl); |
|
|
|
|
socket.onerror = function (e) { |
|
|
|
|
Log("* Connection error"); |
|
|
|
|
Log("Connection error"); |
|
|
|
|
console.log(e); |
|
|
|
|
}; |
|
|
|
|
socket.onopen = function (e) { |
|
|
|
@ -329,7 +338,7 @@ function Connect() {
|
|
|
|
|
|
|
|
|
|
w(MessageNick, nickname); |
|
|
|
|
|
|
|
|
|
updateVoiceStatus(); |
|
|
|
|
updateUserStatus(); |
|
|
|
|
}; |
|
|
|
|
socket.onmessage = function (e) { |
|
|
|
|
if (ReconnectDelay > 0) { |
|
|
|
@ -355,25 +364,25 @@ function Connect() {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Log("* " + escapeEntities(p.N) + " connected"); |
|
|
|
|
Log(escapeEntities(p.N) + " connected"); |
|
|
|
|
} else if (p.T == MessageJoin) { |
|
|
|
|
if (p.N === undefined) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Log("* " + escapeEntities(p.N) + " joined #lobby voice chat"); |
|
|
|
|
Log(escapeEntities(p.N) + " joined #lobby voice chat"); |
|
|
|
|
} else if (p.T == MessageQuit) { |
|
|
|
|
if (p.N === undefined) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Log("* " + escapeEntities(p.N) + " quit #lobby voice chat"); |
|
|
|
|
Log( escapeEntities(p.N) + " quit #lobby voice chat"); |
|
|
|
|
} else if (p.T == MessageDisconnect) { |
|
|
|
|
if (p.N === undefined) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Log("* " + escapeEntities(p.N) + " disconnected"); |
|
|
|
|
Log(escapeEntities(p.N) + " disconnected"); |
|
|
|
|
} else if (p.T == MessageChat) { |
|
|
|
|
if (p.N === undefined) { |
|
|
|
|
return; |
|
|
|
@ -395,8 +404,7 @@ function Connect() {
|
|
|
|
|
|
|
|
|
|
userListStatus = "Users: " + usersconnected + " - Voice chatting: " + usersvoice; |
|
|
|
|
|
|
|
|
|
$("#voiceinactiveright").html(userListStatus); |
|
|
|
|
updateVoiceStatus(); |
|
|
|
|
updateUserStatus(); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// TODO Binary data
|
|
|
|
@ -407,7 +415,7 @@ function Connect() {
|
|
|
|
|
}; |
|
|
|
|
socket.onclose = function (e) { |
|
|
|
|
connected = false; |
|
|
|
|
Log("* Disconnected"); |
|
|
|
|
Log("Disconnected"); |
|
|
|
|
if (ReconnectDelay < 0 || reconnectTimeout != null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -459,7 +467,7 @@ function StartPTT() {
|
|
|
|
|
var sender = peerConnections[0].getSenders()[0]; |
|
|
|
|
sender.replaceTrack(audioTrack); |
|
|
|
|
|
|
|
|
|
updateVoiceStatus(); |
|
|
|
|
updateUserStatus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function StopPTT() { |
|
|
|
@ -472,14 +480,14 @@ function StopPTT() {
|
|
|
|
|
var sender = peerConnections[0].getSenders()[0]; |
|
|
|
|
sender.replaceTrack(null); |
|
|
|
|
|
|
|
|
|
updateVoiceStatus(); |
|
|
|
|
updateUserStatus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateVoiceStatus() { |
|
|
|
|
function updateUserStatus() { |
|
|
|
|
if (ptt) { |
|
|
|
|
$('#voiceactiveleft').html('<b>Transmitting</b>'); |
|
|
|
|
$('#userstatus').html('<b>Transmitting</b>'); |
|
|
|
|
} else { |
|
|
|
|
$('#voiceactiveleft').html(userListStatus); |
|
|
|
|
$('#userstatus').html(userListStatus); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|