def __init__(self, root, connection, address, session_id):
		'initial setup for the connected client'
		self._root = root
		self.conn = connection
		
		# detects if the connection is from this computer
		if address[0].startswith('127.'):
			if root.online_ip:
				address = (root.online_ip, address[1])
			elif root.local_ip:
				address = (root.local_ip, address[1])
		
		self.ip_address = address[0]
		self.local_ip = address[0]
		self.port = address[1]
		
		if root.randomflags:
			self.country_code = ip2country.randomcc()
		else:
			self.setFlagByIP(self.ip_address)
		
		self.session_id = session_id
		self.db_id = session_id
		
		self.handler = None
		self.static = False
		self._protocol = None
		self.removing = False
		self.sendError = False
		self.msg_id = ''
		self.sendbuffer = []
		self.sendingmessage = ''
		self.logged_in = False
		self.status = '12'
		self.cpu = 0
		self.access = 'fresh'
		self.accesslevels = ['fresh','everyone']
		self.channels = []
		
		self.battle_bots = {}
		self.current_battle = None
		self.battle_bans = []
		self.ingame_time = 0
		self.went_ingame = 0
		self.spectator = False
		self.battlestatus = {'ready':'0', 'id':'0000', 'ally':'0000', 'mode':'0', 'sync':'00', 'side':'00', 'handicap':'0000000'}
		self.teamcolor = '0'
		
		self.username = ''
		self.password = ''
		self.hostport = None
		self.udpport = 0
		self.bot = 0
		self.hook = ''
		self.floodlimit = {'fresh':{'msglength':1024, 'bytespersecond':1024, 'seconds':2},
							'user':{'msglength':1024, 'bytespersecond':1024, 'seconds':10},
							'bot':{'msglength':1024, 'bytespersecond':10240, 'seconds':5},
							'mod':{'msglength':10240, 'bytespersecond':10240, 'seconds':10},
							'admin':{'disabled':True},}
		self.msglengthhistory = {}
		self.lastsaid = {}
		self.nl = '\n'
		self.telnet = False
		self.current_channel = ''
		self.blind_channels = []
		self.reverse_ignore = []
		
		self.tokenized = False
		self.hashpw = False
		self.debug = False
		self.data = ''

		# holds compatibility flags - will be set by Protocol as necessary
		self.compat = defaultdict(lambda: False)
		self.scriptPassword = None
		
		now = time.time()
		self.last_login = now
		self.register_date = now
		self.lastdata = now
		self.last_id = 0
		
		self.users = set([]) # session_id
		self.battles = set([]) # [battle_id] = [user1, user2, user3, etc]
		
		self._root.console_write('Client connected from %s, session ID %s.' % (self.ip_address, session_id))
dataset/ETHPy150Open lunixbochs/uberserver/Client.py/Client.__init__/original