Fixed the websocket example to also work for remote client.

(i.e not from the same machine).
This commit is contained in:
Jocelyn Fiat
2017-12-18 14:52:09 +01:00
parent e9292b3eac
commit 36eeff9285

View File

@@ -27,7 +27,7 @@ feature -- Basic operations
-- To send a response we need to setup, the status code and
-- the response headers.
if request.path_info.same_string_general ("/app") then
s := websocket_app_html (9090)
s := websocket_app_html (request.server_name, request.server_port)
else
s := "Hello World!"
create dt.make_now_utc
@@ -184,7 +184,7 @@ feature -- Command
feature -- HTML Resource
websocket_app_html (a_port: INTEGER): STRING
websocket_app_html (a_host: STRING; a_port: INTEGER): STRING
do
Result := "[
<!DOCTYPE html>
@@ -198,7 +198,7 @@ $(document).ready(function() {
function connect(){
var host = "##WSSCHEME##://127.0.0.1:##PORTNUMBER##/app";
var host = "##WSSCHEME##://##HOSTNAME##:##PORTNUMBER##/app";
try{
@@ -280,6 +280,7 @@ body {font-family:Arial, Helvetica, sans-serif;}
</body>
</html>
]"
Result.replace_substring_all ("##HOSTNAME##", a_host)
Result.replace_substring_all ("##PORTNUMBER##", a_port.out)
if request.is_https then
Result.replace_substring_all ("##HTTPSCHEME##", "https")