diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-06-03 19:45:40 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-06-03 19:45:40 +0100 |
commit | 4858a5cfa9bcc7970c8d3368df3d21b53c5e4b47 (patch) | |
tree | 62c0ac49ca2c2e1b5b6c535357f2c40c9d7a1138 /server.py |
added a first version of the server main function
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'server.py')
-rwxr-xr-x | server.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/server.py b/server.py new file mode 100755 index 0000000..c42a5d0 --- /dev/null +++ b/server.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +from websocket_server import WebsocketServer +from CAO_Cards import CAO_Cards + +def new_client_handler(client, server): + print('client ' + client['id'] + ' just joined') + +def client_left_handler(client, server): + print('client just left') + +def message_received_handler(client, server, message): + print('received from client ' + client['id'] + ': [%s]' % message) + +def main(): + white_cards = CAO_Cards.get_white_cards() + black_cards = CAO_Cards.get_black_cards() + + server = WebsocketServer(1236) + + server.set_fn_new_client(new_client_handler) + server.set_fn_client_left(client_left_handler) + server.set_fn_message_received(message_received_handler) + server.run_forever() + +if __name__ == '__main__': + main() |