leads.comm.server.server#

Module Contents#

Classes#

Server

You should use create_server() and start_server() instead of directly calling any method.

API#

class leads.comm.server.server.Server(port: int, callback: leads.comm.prototype.Callback, separator: bytes)[source]#

Bases: leads.comm.prototype.Entity

You should use create_server() and start_server() instead of directly calling any method.

Initialization

Parameters:
  • port – the port on which the server listens

  • callback – the callback interface

  • separator – the symbol that splits the stream into messages

num_connections() int[source]#

Get the number of active connections. :return: the number of connections

remove_connection(connection: leads.comm.prototype.Connection) None[source]#

Remove the connection from the list. :param connection: the connection to remove

run(max_connection: int = 1) None[source]#

Start listening for the connections and stage each connection in a new thread. :param max_connection: the maximum number of connections allowed at the same time

broadcast(msg: bytes) None[source]#

Send the message to all connected clients. :param msg: the message to send

close() None[source]#

Close all active connections.