Esempio n. 1
0
    def _doFeedTo(self, fullFeedId, t):
        self.debug('flushing PB write queue')
        t.doWrite()
        self.debug('stop writing to transport')
        t.stopWriting()

        # make sure shutdown() is not called on the socket
        t.keepSocketAlive = True

        fd = os.dup(t.fileno())
        # Similar to feedserver._sendFeedReplyCb, but since we are in a
        # callLater, not doReadOrWrite, we call connectionLost directly
        # on the transport.
        t.connectionLost(failure.Failure(main.CONNECTION_DONE))

        # This medium object is of no use any more; drop our reference
        # to the remote so we can avoid cycles.
        self.setRemoteReference(None)

        (flowName, componentName,
         feedName) = common.parseFullFeedId(fullFeedId)
        feedId = common.feedId(componentName, feedName)

        self.debug('firing deferred with feedId %s on fd %d', feedId, fd)
        self._feedToDeferred.callback((feedId, fd))
Esempio n. 2
0
    def _doFeedTo(self, fullFeedId, t):
        self.debug('flushing PB write queue')
        t.doWrite()
        self.debug('stop writing to transport')
        t.stopWriting()

        # make sure shutdown() is not called on the socket
        t.keepSocketAlive = True

        fd = os.dup(t.fileno())
        # Similar to feedserver._sendFeedReplyCb, but since we are in a
        # callLater, not doReadOrWrite, we call connectionLost directly
        # on the transport.
        t.connectionLost(failure.Failure(main.CONNECTION_DONE))

        # This medium object is of no use any more; drop our reference
        # to the remote so we can avoid cycles.
        self.setRemoteReference(None)

        (flowName, componentName, feedName) = common.parseFullFeedId(
            fullFeedId)
        feedId = common.feedId(componentName, feedName)

        self.debug('firing deferred with feedId %s on fd %d', feedId,
                   fd)
        self._feedToDeferred.callback((feedId, fd))
Esempio n. 3
0
    def _doReceiveFeed(self, fullFeedId):
        t = self.mind.broker.transport

        self.debug('flushing PB write queue')
        t.doWrite()
        self.debug('stop writing to transport')
        t.stopWriting()

        # hand off the fd to the component
        self.debug("Attempting to send FD: %d", t.fileno())

        (flowName, componentName,
         eaterAlias) = common.parseFullFeedId(fullFeedId)
        componentId = common.componentId(flowName, componentName)

        if self.feedServer.eatFromFD(componentId, eaterAlias, t.fileno(),
                                     self.avatarId):
            t.keepSocketAlive = True

        t.loseConnection()
Esempio n. 4
0
    def _doReceiveFeed(self, fullFeedId):
        t = self.mind.broker.transport

        self.debug('flushing PB write queue')
        t.doWrite()
        self.debug('stop writing to transport')
        t.stopWriting()

        # hand off the fd to the component
        self.debug("Attempting to send FD: %d", t.fileno())

        (flowName, componentName, eaterAlias) = common.parseFullFeedId(
            fullFeedId)
        componentId = common.componentId(flowName, componentName)

        if self.feedServer.eatFromFD(componentId, eaterAlias, t.fileno(),
                                     self.avatarId):
            t.keepSocketAlive = True

        t.loseConnection()
Esempio n. 5
0
    def _sendFeedReplyCb(self, result, fullFeedId):
        # compare with startStreaming in prototype
        # Remove this from the reactor; we mustn't read or write from it from
        # here on
        t = self.mind.broker.transport
        t.stopReading()
        t.stopWriting()

        # hand off the fd to the component
        self.debug("Attempting to send FD: %d", t.fileno())

        (flowName, componentName,
         feedName) = common.parseFullFeedId(fullFeedId)
        componentId = common.componentId(flowName, componentName)

        if self.feedServer.feedToFD(componentId, feedName, t.fileno(),
                                    self.avatarId):
            t.keepSocketAlive = True

        # We removed the transport from the reactor before sending the
        # FD; now we want the socket cleaned up.
        t.loseConnection()
Esempio n. 6
0
    def _sendFeedReplyCb(self, result, fullFeedId):
        # compare with startStreaming in prototype
        # Remove this from the reactor; we mustn't read or write from it from
        # here on
        t = self.mind.broker.transport
        t.stopReading()
        t.stopWriting()

        # hand off the fd to the component
        self.debug("Attempting to send FD: %d", t.fileno())

        (flowName, componentName, feedName) = common.parseFullFeedId(
            fullFeedId)
        componentId = common.componentId(flowName, componentName)

        if self.feedServer.feedToFD(componentId, feedName, t.fileno(),
                                    self.avatarId):
            t.keepSocketAlive = True

        # We removed the transport from the reactor before sending the
        # FD; now we want the socket cleaned up.
        t.loseConnection()
Esempio n. 7
0
 def _mungeClientId(self, clientId):
     try:
         flowName, compName, feedName = common.parseFullFeedId(clientId)
         return common.feedId(compName, feedName)
     except:
         return clientId
Esempio n. 8
0
 def _mungeClientId(self, clientId):
     try:
         flowName, compName, feedName = common.parseFullFeedId(clientId)
         return common.feedId(compName, feedName)
     except:
         return clientId