예제 #1
0
	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
예제 #2
0
	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
예제 #3
0
	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'] )
예제 #4
0
	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
예제 #5
0
 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
예제 #6
0
 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
예제 #7
0
 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
예제 #8
0
	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
예제 #9
0
 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
예제 #10
0
 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
예제 #11
0
파일: main.py 프로젝트: orsic/MonolithTask
__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)
예제 #12
0
	def receiveData( self ):
		while True:
			data_receive = receive( self.connection, self.packet_size )
			print data_receive
예제 #13
0
	def receiveCountDownRequest( self ):
		data_receive = receive( self.connection, self.packet_size )
예제 #14
0
 def receiveData(self):
     while True:
         data_receive = receive(self.connection, self.packet_size)
         print data_receive
예제 #15
0
 def receiveCountDownRequest(self):
     data_receive = receive(self.connection, self.packet_size)
예제 #16
0
 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'])