def sendStartRequest( self ): start_game_header = { 'cmd': 'START', 'info': { 'player_id': self.player.getPlayerId() } } send( self.connection, start_game_header, self.server ) reply, address = receive( self.connection, self.packet_size ) print reply
def sendQuitRequest( self ): quit_header = { 'cmd': 'QUIT', 'info': { 'player_id': self.player.getPlayerId() } } send( self.connection, quit_header, self.server ) reply, address = receive( self.connection, self.packet_size ) print reply
def sendJoinRequest( self ): join_header = { 'cmd': 'JOIN', 'info': { 'name': self.player.getNick() } } send( self.connection, join_header, self.server ) reply, address = receive( self.connection, self.packet_size ) self.player.setPlayerId( reply['self']['id'] )
def sendReadyRequest( self ): ready_header = { 'cmd': 'READY', 'info': { 'player_id': self.player.getPlayerId() } } send( self.connection, ready_header, self.server ) reply, address = receive( self.connection, self.packet_size ) print reply
def sendQuitRequest(self): quit_header = { 'cmd': 'QUIT', 'info': { 'player_id': self.player.getPlayerId() } } send(self.connection, quit_header, self.server) reply, address = receive(self.connection, self.packet_size) print reply
def sendStartRequest(self): start_game_header = { 'cmd': 'START', 'info': { 'player_id': self.player.getPlayerId() } } send(self.connection, start_game_header, self.server) reply, address = receive(self.connection, self.packet_size) print reply
def sendReadyRequest(self): ready_header = { 'cmd': 'READY', 'info': { 'player_id': self.player.getPlayerId() } } send(self.connection, ready_header, self.server) reply, address = receive(self.connection, self.packet_size) print reply
def sendSnakeDataRequest( self ): snake_header = { 'cmd': 'SNAKEDATA', 'info': { 'player_id': self.player.getPlayerId(), 'data': self.constructor } } send( self.connection, snake_header, self.server ) reply, address = receive( self.connection, self.packet_size ) print reply
def sendSnakeDataRequest(self): snake_header = { 'cmd': 'SNAKEDATA', 'info': { 'player_id': self.player.getPlayerId(), 'data': self.constructor } } send(self.connection, snake_header, self.server) reply, address = receive(self.connection, self.packet_size) print reply
def receive(self): while True: try: request, address = receive(self.listener) if request['cmd'] in self.handler: print '{} comamnd received from {}'.format( request['cmd'], address[0]) self.handler[request['cmd']](self, request, address) else: print request['cmd'] except socket.error: pass
__author__ = 'marin' import connection as conn import parser import observers import models par = parser.Parser() par.add_observer(observers.Poster(parser.JSONParser(), 'http://127.0.0.1:5000/save_count')) par.add_observer(observers.Storer(models.DataModel)) par.add_observer(observers.Printer()) socket = conn.connect() conn.receive(socket, par, 60)
def receiveData( self ): while True: data_receive = receive( self.connection, self.packet_size ) print data_receive
def receiveCountDownRequest( self ): data_receive = receive( self.connection, self.packet_size )
def receiveData(self): while True: data_receive = receive(self.connection, self.packet_size) print data_receive
def receiveCountDownRequest(self): data_receive = receive(self.connection, self.packet_size)
def sendJoinRequest(self): join_header = {'cmd': 'JOIN', 'info': {'name': self.player.getNick()}} send(self.connection, join_header, self.server) reply, address = receive(self.connection, self.packet_size) self.player.setPlayerId(reply['self']['id'])