Example #1
0
	def _name(self):
		# send remote player's name
		msg = ''
		FAIL = ''

		# for these name string msgs, if they are not properly terminated, they need
		# to be 100 chars long to prevent a recv timeout
		if self.chance(self.FAIL_CHANCE): # not xml, no delim
			msg = sp.pack_single_string(sp.random_string(100,100))
			FAIL = 'ERRNO_RECV'
		elif self.chance(self.FAIL_CHANCE): # xml, no delim
			msg = sp.serialize_player_name(sp.random_string(95,95))
			msg = msg[0:-3]
			FAIL = 'ERRNO_RECV'
		elif self.chance(self.FAIL_CHANCE): # malformed xml, with delim
			msg = sp.serialize_player_name(self.state['g'].get_remote_player_name())
			msg = msg[3:]
			FAIL = 'ERR_INVALID_XML'
		else:
			msg = sp.serialize_player_name(self.state['g'].get_remote_player_name())


		self.write(msg)

		if '' != FAIL:
			self._recv_error(FAIL)
			return -1

		return 0
Example #2
0
    def _name(self):
        # send remote player's name
        msg = ''
        FAIL = ''

        # for these name string msgs, if they are not properly terminated, they need
        # to be 100 chars long to prevent a recv timeout
        if self.chance(self.FAIL_CHANCE):  # not xml, no delim
            msg = sp.pack_single_string(sp.random_string(100, 100))
            FAIL = 'ERRNO_RECV'
        elif self.chance(self.FAIL_CHANCE):  # xml, no delim
            msg = sp.serialize_player_name(sp.random_string(95, 95))
            msg = msg[0:-3]
            FAIL = 'ERRNO_RECV'
        elif self.chance(self.FAIL_CHANCE):  # malformed xml, with delim
            msg = sp.serialize_player_name(
                self.state['g'].get_remote_player_name())
            msg = msg[3:]
            FAIL = 'ERR_INVALID_XML'
        else:
            msg = sp.serialize_player_name(
                self.state['g'].get_remote_player_name())

        self.write(msg)

        if '' != FAIL:
            self._recv_error(FAIL)
            return -1

        return 0
Example #3
0
	def _name(self):
		# send remote player's name
		msg = ''
		FAIL = ''

		if self.chance(self.FAIL_CHANCE): # malformed xml, with delim
			msg = sp.serialize_player_name(self.state['g'].get_remote_player_name())
			msg = msg[3:]
			FAIL = 'ERR_INVALID_XML'
		else:
			msg = sp.serialize_player_name(self.state['g'].get_remote_player_name())


		self.write(msg)

		if '' != FAIL:
			self._recv_error(FAIL)
			return -1

		return 0