|
@@ -6,25 +6,20 @@ import webRtcPlayer from './webRtcPlayer'
|
|
|
|
|
|
|
|
|
function parserOptions(options) {
|
|
|
-
|
|
|
- vueContext = options.context;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
serverUrl = options.serverUrl;
|
|
|
|
|
|
- autoConnection = options.autoConnection;
|
|
|
+ connect_on_load = options.autoConnection;
|
|
|
shouldShowPlayOverlay = options.showPlayOverlay;
|
|
|
|
|
|
|
|
|
- matchViewportResolution = options.matchViewportResolution; */
|
|
|
+
|
|
|
|
|
|
- inputOptions.controlScheme =
|
|
|
- options.inputOptions?.controlScheme ?? inputOptions.controlScheme;
|
|
|
- inputOptions.fakeMouseWithTouches =
|
|
|
- options.inputOptions?.fakeMouseWithTouches ??
|
|
|
- inputOptions.fakeMouseWithTouches;
|
|
|
- inputOptions.suppressBrowserKeys =
|
|
|
- options.inputOptions?.suppressBrowserKeys ??
|
|
|
- inputOptions.suppressBrowserKeys;
|
|
|
+ inputOptions.controlScheme = options.inputOptions?.controlScheme ?? inputOptions.controlScheme;
|
|
|
+ inputOptions.fakeMouseWithTouches = options.inputOptions?.fakeMouseWithTouches ?? inputOptions.fakeMouseWithTouches;
|
|
|
+ inputOptions.suppressBrowserKeys = options.inputOptions?.suppressBrowserKeys ?? inputOptions.suppressBrowserKeys;
|
|
|
|
|
|
|
|
|
|
|
@@ -37,6 +32,7 @@ function parserOptions(options) {
|
|
|
...afk,
|
|
|
...options.afk,
|
|
|
};
|
|
|
+ console.log('连接地址:'+serverUrl)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -55,7 +51,7 @@ export const callCommand = emitCommand;
|
|
|
|
|
|
export const callUIInteraction = emitUIInteraction;
|
|
|
|
|
|
-
|
|
|
+var serverUrl
|
|
|
var webRtcPlayerObj = null;
|
|
|
var print_stats = false;
|
|
|
var print_inputs = false;
|
|
@@ -293,8 +289,6 @@ function showConnectOverlay() {
|
|
|
startText.innerHTML = 'Click to start';
|
|
|
startText.style.marginTop = '50vh'
|
|
|
|
|
|
-
|
|
|
-
|
|
|
setOverlay('clickableState', startText, event => {
|
|
|
connect();
|
|
|
startAfkWarningTimer();
|
|
@@ -393,11 +387,13 @@ function resetAfkWarningTimer() {
|
|
|
function createWebRtcOffer() {
|
|
|
if (webRtcPlayerObj) {
|
|
|
|
|
|
- showTextOverlay('Starting connection to server, please wait');
|
|
|
+
|
|
|
+ console.log('Starting connection to server, please wait')
|
|
|
webRtcPlayerObj.createOffer();
|
|
|
} else {
|
|
|
|
|
|
- showTextOverlay('Unable to setup video');
|
|
|
+
|
|
|
+ console.log('Unable to setup video')
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -459,7 +455,8 @@ function setupWebRtcPlayer(htmlElement, config) {
|
|
|
|
|
|
webRtcPlayerObj.onDataChannelConnected = function () {
|
|
|
if (ws && ws.readyState === WS_OPEN_STATE) {
|
|
|
- showTextOverlay('WebRTC connected, waiting for video');
|
|
|
+
|
|
|
+ console.log('WebRTC connected, waiting for video')
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -1596,7 +1593,7 @@ function start() {
|
|
|
}
|
|
|
|
|
|
if (!connect_on_load || is_reconnection) {
|
|
|
- showConnectOverlay();
|
|
|
+
|
|
|
invalidateFreezeFrameOverlay();
|
|
|
shouldShowPlayOverlay = true;
|
|
|
resizePlayerStyle();
|
|
@@ -1614,6 +1611,7 @@ function updateKickButton(playersCount) {
|
|
|
}
|
|
|
|
|
|
function connect() {
|
|
|
+ document.getElementById('connecting').style.display = 'none'
|
|
|
"use strict";
|
|
|
|
|
|
window.WebSocket = window.WebSocket || window.MozWebSocket;
|
|
@@ -1625,10 +1623,7 @@ function connect() {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
- ws = new WebSocket('ws://172.16.58.195:8080');
|
|
|
-
|
|
|
-
|
|
|
+ ws = new WebSocket(serverUrl.replace('http://', 'ws://'));
|
|
|
|
|
|
ws.onmessage = function (event) {
|
|
|
|
|
@@ -1647,11 +1642,12 @@ function connect() {
|
|
|
};
|
|
|
|
|
|
ws.onerror = function (event) {
|
|
|
-
|
|
|
+ console.log(`WS error: ${JSON.stringify(event)}`);
|
|
|
};
|
|
|
|
|
|
ws.onclose = function (event) {
|
|
|
-
|
|
|
+ document.getElementById('connecting').style.display = 'block'
|
|
|
+ console.log(`WS closed: ${JSON.stringify(event.code)} - ${event.reason}`);
|
|
|
ws = undefined;
|
|
|
is_reconnection = true;
|
|
|
|
|
@@ -1663,8 +1659,11 @@ function connect() {
|
|
|
webRtcPlayerObj = undefined;
|
|
|
}
|
|
|
|
|
|
- showTextOverlay(`Disconnected: ${event.reason}`);
|
|
|
- var reclickToStart = setTimeout(start, 4000);
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ connect()
|
|
|
+ }, 2000);
|
|
|
+
|
|
|
};
|
|
|
}
|
|
|
|