Ejemplo n.º 1
0
def PReqLogin(seqID, svcID, gameID, category):
    req = presence_pb2.PReqProtocol()
    req.command = presence_pb2.LOGIN
    req.seqID = seqID
    req.svcID = svcID
    req.gameID = gameID
    req.category = category
    return req
Ejemplo n.º 2
0
def PReqCategory(seqID, svcID, gameID, category):
    req = presence_pb2.PReqProtocol()
    req.command = presence_pb2.CATEGORY
    req.seqID = seqID
    req.svcID = svcID
    req.gameID = gameID
    req.category = category
    return req
Ejemplo n.º 3
0
def PReqDetach(seqID, svcID, gameID, category):
    req = presence_pb2.PReqProtocol()
    req.command = presence_pb2.DETACH
    req.seqID = seqID
    req.svcID = svcID
    req.gameID = gameID
    req.category = category
    return req
Ejemplo n.º 4
0
def PReqGameLeave(seqID, svcID, gameID, category):
    req = presence_pb2.PReqProtocol()
    req.command = presence_pb2.GAMELEAVE
    req.seqID = seqID
    req.svcID = svcID
    req.gameID = gameID
    req.category = category
    return req
Ejemplo n.º 5
0
def PReqGameEnter(seqID, svcID, gameID, category):
    req = presence_pb2.PReqProtocol()
    req.command = presence_pb2.GAMEENTER
    req.seqID = seqID
    req.svcID = svcID
    req.gameID = gameID
    req.category = category
    return req
Ejemplo n.º 6
0
 def _buildRequest(self, command, gameID, category=0):
     req = presence_pb2.PReqProtocol()
     req.gameID = gameID
     req.command = command
     req.seqID = 0
     req.svcID = 100
     req.category = category
     return req
Ejemplo n.º 7
0
	def process(self, request):
		req = presence_pb2.PReqProtocol()
		req.ParseFromString(request)
		command = req.command

		# check ppID & gameID

		self.gameID = req.gameID

		seqID = req.seqID
		gameID = req.gameID
		svcID = req.svcID
		category = req.category

		res = False

		if command == presence_pb2.LOGIN:
			res = self.login(gameID, seqID, svcID)
		elif command == presence_pb2.LOGOUT:
			res = self.logout(gameID, seqID, svcID)
		elif command == presence_pb2.GAMEENTER:
			res = self.gameEnter(gameID, seqID, svcID, category)
		elif command == presence_pb2.GAMELEAVE:
			res = self.gameLeave(gameID, seqID, svcID)
		elif command == presence_pb2.DETACH:
			res = self.detach(gameID, seqID, svcID)
		elif command == presence_pb2.PLUG:
			res = self.plug(gameID, seqID, svcID)
		else:
			command = presence_pb2.NONE
			
			
		state = res[1]
		ans = presence_pb2.PAnsProtocol()
		ans.command = command
		ans.seqID = seqID
		ans.gameID = gameID
		ans.svcID = svcID
		ans.category = category

		ans.result = res[0]
		ans.status = state[0]
		ans.detached = state[1]
		if state[0] == 'G':
			ans.ip = state[2][0]
			ans.port = state[2][1]
			ans.roomID = state[2][2]

		packet = ans.SerializeToString()
		header = pack("I", len(packet))
		header += packet
		self.transport.write(header)
Ejemplo n.º 8
0
	def process(self, request):
		req = presence_pb2.PReqProtocol()
		req.ParseFromString(request)
		command = req.command

		# check ppID & gameID

		seqID = req.seqID
		gameID = req.gameID
		svcID = req.svcID
		category = req.category

		res = False
	
		print 'req:', command, gameID, seqID, svcID

		if self.gameID == False:
			if command == presence_pb2.LOGIN:
				res = self.login(gameID, seqID, svcID)
				if res[0]!= False: 
					self.gameID = gameID
		elif self.gameID == gameID:
			if command == presence_pb2.LOGOUT:
				res = self.logout(gameID, seqID, svcID)
                if res[0] == True:
                    self.gameID = False
			elif command == presence_pb2.GAMEENTER:
				res = self.gameEnter(gameID, seqID, svcID, category)
			elif command == presence_pb2.GAMELEAVE:
				res = self.gameLeave(gameID, seqID, svcID)
			elif command == presence_pb2.DETACH:
				res = self.detach(gameID, seqID, svcID)
			elif command == presence_pb2.PLUG:
				res = self.plug(gameID, seqID, svcID)
			elif command == presence_pb2.CATEGORY:
				res = self.category(gameID, seqID, svcID)
			else:
				command = presence_pb2.NONE