本文整理汇总了Python中MessageParser.MessageParser.parse_login方法的典型用法代码示例。如果您正苦于以下问题:Python MessageParser.parse_login方法的具体用法?Python MessageParser.parse_login怎么用?Python MessageParser.parse_login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageParser.MessageParser
的用法示例。
在下文中一共展示了MessageParser.parse_login方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from MessageParser import MessageParser [as 别名]
# 或者: from MessageParser.MessageParser import parse_login [as 别名]
class Client:
"""
This is the chat client class
"""
def __init__(self, host, server_port):
"""
This method is run when creating a new Client object
"""
# Set up the socket connection to the server
self.connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.messageParser = MessageParser()
self.host = ""
self.server_port = 9998
# TODO: Finish init process with necessary code
self.run()
self.messageReceiver = MessageReceiver(self,self.connection)
self.messageReceiver.start()
def run(self):
# Initiate the connection to the server
self.connection.connect((self.host, self.server_port))
def disconnect(self):
self.messageReceiver.send_disconnect()
self.connection.close()
quit()
def receive_message(self, message):
self.messageParser.parse(self.printer, message)
def printer(self,time,sender,message_type,message):
melding = ("\n[" +
time +" : " + message_type + "] " +
sender+ ": " + message + "\n>>> ")
print melding
def send_payload(self, data):
if data == "getHistory":
self.messageReceiver.getHistory()
elif data == "getNames":
self.messageReceiver.getNames()
elif data == "getHelp":
self.messageReceiver.getHelp()
else:
self.messageReceiver.sendMessage(data)
def login(self, data):
brukerNavn = self.messageParser.parse_login(data)
self.messageReceiver.send_login(brukerNavn)