KnutServer¶
-
class
knut.server.KnutServer(address: str, port: int)¶ Base class for Knut servers.
Note
Each subclass must implement
knut_serve_forever().Bind to the address and listen on the port for requests.
-
add_api(api: knut.apis.knutapi.KnutAPI) → None¶ Adds a api to the server.
The api is added to the dictionary of APIs and it’s
on_push()event is connected to the servers request handler to push messages.The request handler will also call the APIs
request_handler()method if the API’s service matches the requested service.
-
address= None¶ The address to which the server is bound.
-
apis= None¶ A dictionary with all APIs as value and their corresponding service ids as keys. See
add_api()for more about adding an API.
-
knut_serve_forever()¶ The main event loop of the server.
Warning
Must be implemented by a subclass.
-
port= None¶ The port on which the server listens.
-