def sendMessage(self, message, subchannel, channel = None, typeName = None, asObject = False, asDatagram = False): """ Send a direct message to the client. @type message: str/number/ByteReader @param subchannel: The subchannel of the message in the range 0-256 @param typeName: If not specified, the type will be automatically detected (see L{lacewing.packetloaders.common.DATA_TYPES} for possible values) """ if typeName is None: typeName = detectType(message) if asObject: if channel is None: newMessage = server.ObjectServerMessage() else: newMessage = server.ObjectServerChannelMessage() else: if channel is None: newMessage = server.BinaryServerMessage() else: newMessage = server.BinaryServerChannelMessage() newMessage.value = message newMessage.subchannel = subchannel if channel is not None: newMessage.channel = channel.id newMessage.setDataType(typeName) self.sendLoader(newMessage, asDatagram)
def sendMessage(self, message, subchannel = 0, fromConnection = None, asObject = False, typeName = None, **settings): """ Send a channel message from the given protocol instance. @param fromConnection: The client that the message is sent from (or None if the message is from the server). @param message: The message to send. @type message: str/number/ByteReader @param subchannel: The subchannel to send the message on. @type subchannel: number @param typeName: If not specified, the type will be automatically detected (see L{lacewing.packetloaders.common.DATA_TYPES} for possible values) """ if typeName is None: typeName = detectType(message) if asObject: if fromConnection is None: newMessage = server.ObjectServerChannelMessage() else: newMessage = server.ObjectChannelMessage() else: if fromConnection is None: newMessage = server.BinaryServerChannelMessage() else: newMessage = server.BinaryChannelMessage() newMessage.channel = self.id newMessage.value = message newMessage.subchannel = subchannel if fromConnection is not None: newMessage.peer = fromConnection.id newMessage.setDataType(typeName) self.sendLoader(newMessage, [fromConnection], **settings)
def sendPrivateMessage(self, message, subchannel, sender, recipient, asObject = False, typeName = None, **settings): """ Send a message from this client to a recipient @type message: str/number/ByteReader @param subchannel: The subchannel of the message in the range 0-256 @param sender: Sending connection @type sender: L{ServerProtocol} object @param recipient: Connection to send message to @type recipient: L{ServerProtocol} object @param typeName: If not specified, the type will be automatically detected (see L{lacewing.packetloaders.common.DATA_TYPES} for possible values) """ if typeName is None: typeName = detectType(message) if asObject: newMessage = server.ObjectPeerMessage() else: newMessage = server.BinaryPeerMessage() newMessage.channel = self.id newMessage.value = message newMessage.subchannel = subchannel newMessage.peer = sender.id newMessage.setDataType(typeName) recipient.sendLoader(newMessage, **settings)
def sendMessage(self, message, subchannel, typeName = None, asObject = False, asDatagram = False): """ Send a message to another peer @type message: str/number/ByteReader @param subchannel: The subchannel of the message in the range 0-256 @param typeName: If not specified, the type will be automatically detected (see L{lacewing.packetloaders.common.DATA_TYPES} for possible values) """ if asObject: newMessage = client.ObjectPeerMessage() else: newMessage = client.BinaryPeerMessage() newMessage.value = message newMessage.subchannel = subchannel newMessage.channel = self.channel.id newMessage.peer = self.id newMessage.setDataType(typeName or detectType(message)) self.user.sendLoader(newMessage, asDatagram)