Commit 34c3ef80 authored by Antoine Millet's avatar Antoine Millet

Added search_client_by_connection method on CCServer.

Also updated the CCClient class to make its attributes publics.
parent 954621fc
......@@ -71,6 +71,21 @@ class CCServer(object):
self._connected[login] = CCClient(login, role, self, connection)
def search_client_by_connection(self, connection):
Search a connected client by it connection. If no client is found,
return None.
:param connection: the connection of the client to search
:return: the found client or None
for client in self._connected.values():
if client.connection is connection:
return client
return None
def run(self):
Run the server mainloop.
......@@ -9,13 +9,13 @@ class CCClient(object):
def __init__(self, login, role, server, connection):
# The login of the client:
self._login = login
self.login = login
# The role of the client:
self._role = role
self.role = role
# The server binded to this client:
self._server = server
self.server = server
# The connection of the client (public attribute):
self.connection = connection
......@@ -30,10 +30,10 @@ class CCClient(object):
# Get the tags from the server
tags ='get_tags', tags)
# Add the static tags:
tags['a'] = self._login
tags['hv'] = self._login
tags['role'] = self._role
tags['a'] = self.login
tags['hv'] = self.login
tags['role'] = self.role
# Update it with the locally defined tags:
return tags
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment