core :: union_find
union–find algorithm using an efficient disjoint-set data structure
# Sample module for a minimal chat server using Websockets on port 8088
module websocket_server is example
import websocket
var sock = new WebsocketServer.with_infos(8088, 1)
var msg: String
if sock.listener.closed then
print sys.errno.strerror
end
var cli: WebsocketConnection
while not sock.closed do
cli = sock.accept
while cli.connected do
if sys.stdin.poll_in then
msg = gets
printn "Sending message : {msg}"
if msg == "disconnect" then cli.close
cli.write(msg)
end
if cli.can_read(10) then
msg = ""
while cli.can_read(0) do msg += cli.read(100)
if msg != "" then print msg
end
end
end
lib/websocket/examples/websocket_server.nit:17,1--47,3