How to send data with a tcp server?
In the client you get all sorts job read/write methods. How do I send stuff from the server to the client? Do I just make another client on the server machine and use that to send?
Again, docs need to be improved. Source code is not documentation.
Also, when attempting to use a tcp client
`createTcpClient(<my local ip>, 6767)
The net module error message is related to nodejs. In nodejs there is a net module allowing raw sockets, but it is not the case on browsers, I switch to one implementation or another detecting the environment (node or browser). In the case of tcp client it seems I was not throwing a non supported exception on browsers and just tried the nodejs way.
And then I hit the problem of not being able to set up a web socket server in JS. @soywiz
You can use any modern web server supporting websockets. If you want to use the jvm on the server side you can use ktor:
(I dont remember if I also implemented server-side websockets on korio.)
You can also use nodejs if you eant to use js in the server:
In the end it is a normal web http server where some routes are stateful and get upgraded to the bidirectional frame-based websocket protocol.
@soywiz So there's absolutely no way to have the server in JS? Was hoping for offline lan, just using JS; Do I need to have one machine host the server in a jar or something?
What I really need is a tutorial on how to use your implementation of sockets. Anyone who uses your apps needs more docs........ I’m going to put the new info you’ve been giving me in the doc.(pr) but really, spend a few hours just documenting your apis. It cuts down on wait time for your users, and your time answering these questions.
soywiz last edited by soywiz
The only API I'm aware of for simulating a web server on the client is a service worker, but obviously that API is limited to the browser that created the service worker.
That would be a security problem if browsers could do that.
The only way to integrate a game in JS + doing not secure stuffs like creating a webserver is by using something like electron ( https://electronjs.org/ ). But then people won't be able to just connect to an url to play the game.
Again, WebRTC might help there:
Regarding to docs. Yeah, I'm aware of that. The problem is that I don't have time for everything (Think that I have a job not related to this, so I can't invest all the time I would like). So I'm doing it at my own pace, per request, and of course accepting PRs improving it