class ShiriToriCommType(object):
    '''Manages communication for shiritori game'''
    def __init__(self):
        '''Set up shiritori game instance'''
        self.shi = ShiriToriInstanceType()
    def register_socket(self, socket):
        '''Tell shiritori instance a player has entered'''
        self.shi.add_player(socket)

    def deregister_socket(self, socket):
        '''Tell shiritori instance a player logged off'''
        self.shi.remove_player(socket)

    def handle_server_message(self, socket, message_string):
        '''Relay server message to shiritori instance'''
        message = json.loads(message_string)
        if message['action'] == 'nextWord':
            self.shi.next_word(socket, message)
        elif message['action'] == 'getWords':
            self.shi.send_words(socket)
Example #2
0
class ShiriToriCommType(object):
    '''Manages communication for shiritori game'''
    def __init__(self):
        '''Set up shiritori game instance'''
        self.shi = ShiriToriInstanceType()

    def register_socket(self, socket):
        '''Tell shiritori instance a player has entered'''
        self.shi.add_player(socket)

    def deregister_socket(self, socket):
        '''Tell shiritori instance a player logged off'''
        self.shi.remove_player(socket)

    def handle_server_message(self, socket, message_string):
        '''Relay server message to shiritori instance'''
        message = json.loads(message_string)
        if message['action'] == 'nextWord':
            self.shi.next_word(socket, message)
        elif message['action'] == 'getWords':
            self.shi.send_words(socket)
Example #3
0
 def __init__(self):
     '''Set up shiritori game instance'''
     self.shi = ShiriToriInstanceType()
 def __init__(self):
     '''Set up shiritori game instance'''
     self.shi = ShiriToriInstanceType()