mirror of
https://github.com/googleforgames/open-match.git
synced 2025-03-27 08:20:47 +00:00
.github
api
cmd
docs
examples
demo
bytesub
components
static
dashboard.js
index.html
updater
demo.go
functions
scale
install
internal
pkg
test
third_party
tools
tutorials
.dockerignore
.gcloudignore
.gitignore
.golangci.yaml
CONTRIBUTING.md
Dockerfile.base-build
Dockerfile.ci
Dockerfile.cmd
LICENSE
Makefile
README.md
cloudbuild.yaml
code-of-conduct.md
doc.go
go.mod
go.sum
This fixes the scenario where the demo is behind an https proxy. In that scenario, it would previously try to connect via unsecured websockets, which doesn't work. Specifically, this is the case for Google Cloud Console's Web Preview. Tested=Manually, bridging locally and also with the Cloud Console.
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
// Copyright 2019 Google LLC
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
window.onload = function() {
|
|
let protocol = "ws://";
|
|
if (window.location.protocol == "https:") {
|
|
protocol = "wss://";
|
|
}
|
|
const ws = new WebSocket(protocol + window.location.host + "/connect");
|
|
|
|
ws.onopen = function (event) {
|
|
return false;
|
|
}
|
|
|
|
ws.onmessage = function (event) {
|
|
document.getElementById("content").textContent = event.data;
|
|
return false;
|
|
}
|
|
|
|
ws.onerror = function (event) {
|
|
console.log("ERROR!");
|
|
console.log(event);
|
|
document.getElementById("error").textContent = event.toString();
|
|
return false;
|
|
}
|
|
|
|
ws.onclose = function (event) {
|
|
console.log("WS CLOSED!");
|
|
console.log(event);
|
|
document.getElementById("error").textContent = event.toString();
|
|
return false;
|
|
}
|
|
}
|