Produces Websocket client-server connections
websocket :: WebsocketServer :: accept
Accepts an incoming connectionwebsocket :: WebsocketServer :: listener
Socket listening for incoming Websocket connectionswebsocket :: WebsocketServer :: listener=
Socket listening for incoming Websocket connectionswebsocket :: WebsocketServer :: with_infos
Creates a new Websocket server listening on given portwebsocket $ WebsocketServer :: SELF
Type of this instance, automatically specialized in every classwebsocket :: WebsocketServer :: accept
Accepts an incoming connectioncore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
websocket :: WebsocketServer :: listener
Socket listening for incoming Websocket connectionswebsocket :: WebsocketServer :: listener=
Socket listening for incoming Websocket connectionscore :: Object :: output_class_name
Display class name on stdout (debug only).websocket :: WebsocketServer :: with_infos
Creates a new Websocket server listening on given port
# Websocket compatible server
#
# Produces Websocket client-server connections
class WebsocketServer
# Socket listening for incoming Websocket connections
var listener: TCPServer
# Is `self` closed?
var closed = false
# Creates a new Websocket server listening on given port
# with `max_clients` slots available
init with_infos(port: Int, max_clients: Int)
do
var listener = new TCPServer(port)
listener.listen max_clients
init(listener)
end
# Accepts an incoming connection
fun accept: WebsocketConnection
do
assert not listener.closed
var client = listener.accept
assert client != null
return new WebsocketConnection(client)
end
# Close the server and the socket below it
fun close
do
listener.close
closed = true
end
end
lib/websocket/websocket.nit:24,1--61,3