<commit_before># -*- coding: utf-8 -*-
"""
    BobSwitch 
    ~~~~~~~~~~~~~~

    Online HTML5 version of the backpackers card game switch, also known as crazy eights 
    and a lot of different names.  This version follows the rules that I know.

    :copyright: (c) Copyright 2013 by Bob
    :license: BSD, see LICENSE for more details.
"""

import tornado.ioloop
import sockjs.tornado
import engine

from sockjs_ext import EventSocketConnection, event


class SocketConnection(EventSocketConnection):
    participants = set()

    def on_open(self, info):
        self.broadcast(self.participants, "Someone joined.")

        # Add client to the clients list
        self.participants.add(self)

    def on_close(self):
        # Remove client from the clients list and broadcast leave message
        self.participants.remove(self)

        self.broadcast(self.participants, "Someone left.")

    @event("chat:message")
    def chat_message(self, message):
        self.broadcast_event(self.participants, "chat:message", message)
        print message

if __name__ == "__main__":
    import logging
    logging.getLogger().setLevel(logging.DEBUG)

    BobSwitchRouter = sockjs.tornado.SockJSRouter(SocketConnection, '/bobswitch')<commit_msg>temporarily return user name on message<commit_after># -*- coding: utf-8 -*-
"""
    BobSwitch 
    ~~~~~~~~~~~~~~

    Online HTML5 version of the backpackers card game switch, also known as crazy eights 
    and a lot of different names.  This version follows the rules that I know.

    :copyright: (c) Copyright 2013 by Bob
    :license: BSD, see LICENSE for more details.
"""

import tornado.ioloop
import sockjs.tornado
import engine

from sockjs_ext import EventSocketConnection, event


class SocketConnection(EventSocketConnection):
    participants = set()

    def on_open(self, info):
        self.broadcast(self.participants, "Someone joined.")

        # Add client to the clients list
        self.participants.add(self)

    def on_close(self):
        # Remove client from the clients list and broadcast leave message
        self.participants.remove(self)

        self.broadcast(self.participants, "Someone left.")

    @event("chat:message")
    def chat_message(self, message):
        self.broadcast_event(self.participants, "chat:message", self.name + message)
        print message

    @event("account:login")
    def login(self, message):
        self.name = message
        self.broadcast_event(self.participants, "chat:message", message + " has joined")


if __name__ == "__main__":
    import logging
    logging.getLogger().setLevel(logging.DEBUG)

    BobSwitchRouter = sockjs.tornado.SockJSRouter(SocketConnection, '/bobswitch')
{'fraction_non_alphanumeric': 0.10203327171903882, 'fraction_numerical': 0.0044362292051756, 'mean_word_length': 3.4215686274509802, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5072701', 'n_tokens_mistral': 789, 'n_tokens_neox': 737, 'n_words': 230}