本文整理汇总了Python中Client.Client.name方法的典型用法代码示例。如果您正苦于以下问题:Python Client.name方法的具体用法?Python Client.name怎么用?Python Client.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client.Client
的用法示例。
在下文中一共展示了Client.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mkDevice
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import name [as 别名]
def mkDevice(screen, x, y, id):
if id.isdigit():
subnet = Subnet(screen, x, y)
subnet.IP = IP(int(id))
return subnet
elif id == "N":
dns = DNS(screen, x, y)
dns.IP = str(ord(list(id)[0]))
return dns
elif id.isupper():
router = Router(screen, x, y)
router.IP = str(ord(list(id)[0]))
router.selected = router.IP == "66"
return router
elif id.islower():
if id == "h":
host = Client(screen, x, y)
host.name = "Alice"
host.corespondent = "Bob"
elif id == "x":
host = Client(screen, x, y)
host.name = "Bob"
host.corespondent = "Alice"
else:
host = Host(screen, x ,y)
host.IP = str(ord(list(id)[0]))
return host
else:
print "Unrecognized unique identifier in sprite map"
return None
示例2: serviceJoiningPlayer
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import name [as 别名]
def serviceJoiningPlayer(self, cl):
if cl[2] == 0:
fn = False
try:
ubt = ord(cl[0].recv(1))
fn = True
except: pass
if not fn:
return
if fn:
fn = False
try:
exb = ord(cl[0].recv(1))
fn = True
except: pass
if fn:
if ubt == PLAYER_JOIN:
cl[2] = 1
cl[3] = exb
else:
kickTempClient(self, cl)
return
if cl[2] == 1:
"""if len(self.clients) >= c.maxPlayers:
cl[0].send(chr(SERVER_FULL))
kickTempClient(self, cl)
return"""
fn = False
try:
nam = str(cl[0].recv(cl[3]))
fn = True
except: pass
if fn:
if len(self.clients) >= c.maxPlayers and cl[1][0] != "127.0.0.1":
cl[0].send(chr(SERVER_FULL))
cl.append(nam)
kickTempClient(self, cl)
return
serverJoinUpdate(self, cl[0])
p = Client()
p.s = cl[0]
p.ip = cl[1][0]
p.rport = cl[1][1]
p.name = nam
p.name = p.name[0:MAX_PLAYERNAME_LENGTH-1]
p.name = p.name.replace("#", " ")
print p.name, "connected (IP: " + p.ip + ")."
self.clients.append(p)
serverPlayerJoin(self, p.name)
del self.tempClients[self.tempClients.index(cl)]
del cl