Ejemplo n.º 1
0
    def writeToServer(self, action, *args, **kw):        
        logger.debug(("writeToServer(" + action + ", [" + ', '.join(args) + "])"))
        
        block = QtCore.QByteArray()
        out = QtCore.QDataStream(block, QtCore.QIODevice.ReadWrite)
        out.setVersion(QtCore.QDataStream.Qt_4_2)
        out.writeUInt32(0)
        out.writeQString(action)
        
        for arg in args :            
            if type(arg) is IntType:
                out.writeInt(arg)
            elif isinstance(arg, basestring):
                out.writeQString(arg)
            elif type(arg) is FloatType:
                out.writeFloat(arg)
            elif type(arg) is ListType:
                out.writeQVariantList(arg)
            else:
                logger.warn("Uninterpreted Data Type: " + str(type(arg)) + " of value: " + str(arg))
                out.writeQString(str(arg))

        out.device().seek(0)
        out.writeUInt32(block.size() - 4)

        self.bytesToSend = block.size() - 4        
        self.replayVaultSocket.write(block)
Ejemplo n.º 2
0
    def writeToServer(self, action, *args, **kw):
        logger.debug(
            ("writeToServer(" + action + ", [" + ', '.join(args) + "])"))

        block = QtCore.QByteArray()
        out = QtCore.QDataStream(block, QtCore.QIODevice.ReadWrite)
        out.setVersion(QtCore.QDataStream.Qt_4_2)
        out.writeUInt32(0)
        out.writeQString(action)

        for arg in args:
            if type(arg) is IntType:
                out.writeInt(arg)
            elif isinstance(arg, basestring):
                out.writeQString(arg)
            elif type(arg) is FloatType:
                out.writeFloat(arg)
            elif type(arg) is ListType:
                out.writeQVariantList(arg)
            else:
                logger.warn("Uninterpreted Data Type: " + str(type(arg)) +
                            " of value: " + str(arg))
                out.writeQString(str(arg))

        out.device().seek(0)
        out.writeUInt32(block.size() - 4)

        self.bytesToSend = block.size() - 4
        self.replayVaultSocket.write(block)
Ejemplo n.º 3
0
 def disconnected(self):
     logger.debug("Disconnected from server")
Ejemplo n.º 4
0
 def process(self, action, stream):
     logger.debug("Replay Vault Server: " + action)
     self.receiveJSON(action, stream)
Ejemplo n.º 5
0
 def send(self, message):
     data = json.dumps(message)
     logger.debug("Outgoing JSON Message: " + data)
     self.writeToServer(data)
Ejemplo n.º 6
0
 def disconnected(self):
     logger.debug("Disconnected from server")
Ejemplo n.º 7
0
 def process(self, action, stream):
     logger.debug("Replay Vault Server: " + action)
     self.receiveJSON(action, stream)
Ejemplo n.º 8
0
 def send(self, message):
     data = json.dumps(message)
     logger.debug("Outgoing JSON Message: " + data)
     self.writeToServer(data)