I’m using: SWI-Prolog version 9.3.8
I want to create a stand alone exe that can be executed in multiples machine without prolog installed, the exe run a web server with a local websocket.
My code looks like this:
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_parameters)).
:- use_module(library(http/websocket)).
:- use_module(library(http/http_error)).
:- use_module(library(http/http_json)).
:- use_module(library(http/json_convert)).
:- use_module(library(http/json)).
main:-
server,
thread_get_message(_).
% Star the server at port 9000
server :-
http_server(http_dispatch, [port(9000)]).
:- http_handler(root(time),
http_upgrade_to_websocket(time_handler, []),
[spawn([])]).
time_handler(WebSocket) :-
ws_receive(WebSocket, Message, [format(json)]),
(
Message.opcode == close
->
true
;
time_response(ResponseDict),
ws_send(WebSocket, json(ResponseDict)),
time_handler(WebSocket)
).
time_response(ResponseDict) :-
get_time(Time),
format_time(string(Message), '%c', Time),
dict_create(Data, _, [message-Message]),
dict_create(ResponseDict, _, [data-Data,format-json,opcode-text]).
And the exe it’s generated with
qsave_program('websocket.exe', [stand_alone(true), foreign(copy), goal(main)]).
The problem occurs when running the exe on another machine as it does not run the websocket because it does not find certain modules, such as http_stream.pl, websocket.pl, etc.