Runs on different ports, uses wss if URL is https.

master
Luka Vandervelden 2019-07-07 12:25:01 +02:00
parent f0295031e9
commit 00badeaf63
2 changed files with 11 additions and 3 deletions

View File

@ -358,7 +358,13 @@ model = {
projects-list: []
}
socket = new WebSocket "ws://localhost:8888/socket"
protocol = if location.protocol == 'https' then 'wss' else 'ws'
port = if location.port then \: + location.port else ''
socket-url = protocol + '://' + location.hostname + port + "/socket"
console.log socket-url
socket = new WebSocket socket-url
socket.onopen = (event) ->
# Nothing to do here ATM.

View File

@ -30,11 +30,13 @@ get "/" do
File.read "index.html"
end
get "/style.css" do
get "/style.css" do |env|
env.response.content_type = "text/css"
File.read "style.css"
end
get "/main.js" do
get "/main.js" do |env|
env.response.content_type = "text/javascript"
File.read "main.js"
end