Hello everyone!
I tried to read a json file from disk and send it as a string to the client in ocsigen. Because after getting longer than 100 lines in my opinion every code file becomes a hell of mess to understand I decided to separate the client code from main.eliom
file and put it into client.ml
and in main.eliom I created a function like:
let read_json path =
let json = Yojson.Basic.from_file path in
Yojson.Basic.Util.to_string json
and when I wanted to call it in client.ml
like: ~%read_json "./static/js/data.json"
I got the error:
Error: Unbound value ~%
Makefile:208: recipe for target '_client/client.cmo' failed
Then I changed my mind to use websocket for rpc and I found WebSocket.webSocket class in js_of_ocaml without any example of how to use it I tried in client and server code this line of code:
let ws_obj = (new WebSockets.webSocket)#url "ws://localhost:8080/json"
in fact without being able to get any results but the error:
Error: Unbound class WebSockets.webSocket
how to make a simple websocket server and use it on client side in two separate files?
any help would be very appreciated. Thanks in advance.