本文整理汇总了Python中PyQt4.QtCore.QDataStream.writeInt64方法的典型用法代码示例。如果您正苦于以下问题:Python QDataStream.writeInt64方法的具体用法?Python QDataStream.writeInt64怎么用?Python QDataStream.writeInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QDataStream
的用法示例。
在下文中一共展示了QDataStream.writeInt64方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendMessage
# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import writeInt64 [as 别名]
def sendMessage(self, msg, args, id = None):
"""Sends a message.
msg -- The message type.
args -- List of message arguments.
id -- An optional socket descriptor. If specified, then the message will only be sent if this connection's socket descriptor matches id."""
if id:
if self.socketDescriptor() != id:
return
msg = Message.fromInt(msg)
if not msg.validateArgs(args):
log.warning("Message %d and args %s have invalid types. Message not sent.", msg, args)
return
if self.client:
log.debug("Sending %s %s", msg, args)
elif self.player and self.player.name:
log.debug("Sending %s %s to %s", msg, args, self.player)
else:
log.debug("Sending %s %s to %s", msg, args, self.peerAddress().toString())
data = QByteArray()
stream = QDataStream(data, self.WriteOnly)
stream.writeInt32(int(msg))
for arg in args:
if type(arg) == str:
stream.writeInt32(len(arg))
stream.writeRawData(arg)
elif type(arg) == int:
stream.writeInt32(arg)
elif type(arg) == long:
stream.writeInt64(arg)
self.write(data)
self.messageSent.emit(msg, args)