src.server.client package

Submodules

src.server.client.client module

Module containing Client and Clients class.

class src.server.client.client.Client(*args)[source]

Bases: object

Class representing single client connecting to the server.

ep

Endpoint tuple.

class src.server.client.client.Clients[source]

Bases: list

Class representing the clients lists.

Stores clients as a server.client.client.Client objects. Extends list type.

find_by_ep(ep)[source]

Find a client in the list knowing its endpoint data. :param ep: endpoint data of the client to find

Returns: client with the given endpoint, or None if none was found

src.server.client.connection module

Module containing Connection and Connections classes.

class src.server.client.connection.Connection(c1, c2=None)[source]

Bases: object

Class representing single connection.

other(c)[source]

Get the other side of the connection.

Given one of the parties of the connection, get the other one.

Parameters:c – given party
Returns:other party from the Connection
remove_client(c)[source]

Remove client.

Remove the client from the connection by placing None at its place.

Parameters:c – client to remove from the connection
Raises:ValueError – if the given client is not present in the connection.
class src.server.client.connection.Connections[source]

Bases: list

Class representing list of connections between clients. Connections are stored as server.client.connection.Connection objects. There should not be more than one one-end connection in the Connections list at once. This is considered as improper behaviour. Extends list type.

add_client(client)[source]

Add new client.

Add new pong_client to the list of connections, either by creating new one-end connection for that particular cilent and appending it to the list in regular way, or by matching the pong_client with some previously connected one, depending on whether there is some one-end connection present.

Parameters:client – client to add
Returns:tuple containing both of the newly connected players if the addition was

performed by inserting the client into existing connection, None if the addition was performed by appending the new one-end connection to the list.

append(x)[source]

Disable calling the regular append method, since the addition of new clients should happen through the add_client() method.

get_pair_of(ep)[source]

Get a pair of the client with the given endpoint.

Parameters:ep – endpoint data of the client
Returns:other client from the connection pair containing the client with the given endpoint
Raises:ValueError – if no client with a given endpoint was found in active connections.

Module contents

Package containing all client-connected utilities for the server. This includes client and connection representations as objects.