當前位置: 首頁>>代碼示例>>Python>>正文


Python Dispatcher.getInstance方法代碼示例

本文整理匯總了Python中iron.dispatcher.Dispatcher.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Python Dispatcher.getInstance方法的具體用法?Python Dispatcher.getInstance怎麽用?Python Dispatcher.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iron.dispatcher.Dispatcher的用法示例。


在下文中一共展示了Dispatcher.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: inInitial_onRequest

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def inInitial_onRequest( self, event ):
		self.lastRequest = event

		# Pass request to TU.
		if self.auto100:
			# Send 100 response to client.
			e = createResponseEvent( event, 100 )
			Dispatcher.getInstance().notify( e )

		self.state.changeState( self.STATE_TRYING )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:12,代碼來源:uas_transaction.py

示例2: inInitial_onRequest

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def inInitial_onRequest( self, event ):
		self.request = event

		self.state.changeState( self.STATE_TRYING )

		# Send request to server.
		Dispatcher.getInstance().notify( Event( self.NOTIFICATION_STARTED ), messageEvent = event ) #FIXME: This notify is also below...

		# Inform the TU.
		Dispatcher.getInstance().notify( Event( self.NOTIFICATION_STARTED ) )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:12,代碼來源:uac_transaction.py

示例3: runTest

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def runTest( self ):
		d = Dispatcher.getInstance()

		c = Context( 'Root' )
		c.start()

		p = TestParent()
		d.add( obj=p, parentObj=None, context=c )

		t = UasTransaction()
		d.add( obj=t, parentObj=None, context=c )
		d.addListener( t, p )

		s = 'SUBSCRIBE sip:[email protected];treats SIP/2.0\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\n\r\n'
		m = Message( s )
		e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
		d.send( e, srcObj = p, dstObj = t )

		s = 'SIP/2.0 100 Trying\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\n\r\n'
		m = Message( s )
		e = MessageEvent( MessageEvent.EVENT_TX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
		d.send( e, srcObj = p, dstObj = t )

		s = 'SIP/2.0 200 OK\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\n\r\n'
		m = Message( s )
		e = MessageEvent( MessageEvent.EVENT_TX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
		d.send( e, srcObj = p, dstObj = t )

		d.send( Event( t.EVENT_TIMER_J ), srcObj = p, dstObj = t )

		c.stop()
開發者ID:CaveMike,項目名稱:mercury,代碼行數:33,代碼來源:test_transaction.py

示例4: changeState

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
    def changeState( self, newState, notify = False ):
        """
        Transition to the new state and optionally notify listeners.
        The state transition will also generate and process internal leave and enter events.
        """

        if self.currentState == None:
            raise Exception( 'This state does not have a current state.' )

        oldState = self.currentState

        # Only execute block if the state is really changing.
        if oldState != newState:
            # Stop state timer.
            self.stopStateTimer()

            # Leave pseudo-event.
            Dispatcher.getInstance().send( StateEvent( self.EVENT_LEAVE, newState = newState, oldState = oldState ), self.obj, self.obj )

            # Change state.
            self.log.info( 'Changing state from %s to %s.' % ( str(oldState), str(newState) ) )
            self.currentState = newState

            # Enter pseudo-event.
            Dispatcher.getInstance().send( StateEvent( self.EVENT_ENTER, newState = newState, oldState = oldState ), self.obj, self.obj )

            # Notify listeners.
            if notify:
                self.log.info( 'Notify listeners of the state change.' )
                Dispatcher.getInstance().notify( StateEvent( self.EVENT_STATE_CHANGE, newState = newState, oldState = oldState ), self.obj )

            # Start state timer.
            self.startStateTimer()
開發者ID:,項目名稱:,代碼行數:35,代碼來源:

示例5: startStateTimer

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
    def startStateTimer( self ):
        """
        If the current state is configured with a state timeout, then start the state timer.
        """

        stateTimeout = self.stateTimeouts.get( self.currentState, None )

        if stateTimeout:
            self.log.info( 'Start state timer with a timeout of ' + str(stateTimeout) + '.' )

            if self.stateTimer:
                self.stopStateTimer()

            self.stateTimer = Dispatcher.getInstance().schedule( stateTimeout, StateEvent( self.EVENT_TIMEOUT, newState = self.currentState ), self.obj, self.obj )
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例6: runTest

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
    def runTest( self ):
        d = Dispatcher.getInstance()

        c = Context( 'Root' )
        c.start()

        o = self.TestObj()
        d.add( obj=o, parentObj=None, context=c )

        o.Start()
        assert( str(o.state.currentState) == o.STATE_STARTED )
        assert( str(o.lastHandler) == 'inStarted_onEnter' )
        o.Pause()
        assert( str(o.state.currentState) == 'Paused' )
        assert( str(o.lastHandler) == 'inPaused_onEnter' )
        o.Stop()
        assert( str(o.state.currentState) == 'Stopped' )
        assert( str(o.lastHandler) == 'inStopped_onEnter' )

        c.stop()
開發者ID:,項目名稱:,代碼行數:22,代碼來源:

示例7: runTest

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def runTest( self ):
		d = Dispatcher.getInstance()

		c = Context( 'Root' )
		c.start()

		dialog = UasDialogSubscribe() #FIXME: pass event?
		d.add( obj=dialog, parentObj=None, context=c )

		s = 'SUBSCRIBE sip:[email protected];treats SIP/2.0\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\nExpires: 3600\r\nCall-ID: abcd\r\n\r\n'
		m = Message( s )
		e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
		d.send( e, srcObj = dialog, dstObj = dialog )

		s = 'SIP/2.0 100 Trying\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\nCall-ID: abcd\r\n\r\n'
		m = Message( s )
		e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
		d.send( e, srcObj = dialog, dstObj = dialog )

		s = 'SIP/2.0 200 OK\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\nCall-ID: abcd\r\n\r\n'
		m = Message( s )
		e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
		d.send( e, srcObj = dialog, dstObj = dialog )

		s = 'SUBSCRIBE sip:[email protected];treats SIP/2.0\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\nCall-ID: abcd\r\nExpires: 0\r\n\r\n'
		m = Message( s )
		e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
		d.send( e, srcObj = dialog, dstObj = dialog )

		s = 'SIP/2.0 200 OK\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\n\r\n'
		m = Message( s )
		e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
		d.send( e, srcObj = dialog, dstObj = dialog )

		sleep( 4 )

		assert 1
開發者ID:CaveMike,項目名稱:mercury,代碼行數:39,代碼來源:test_dialog.py

示例8: inTrying_onEnter

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def inTrying_onEnter( self, event ):
		# Only start timer E if the transport is unreliable.
		if self.request.transport == 'udp':
			self.timerE = Dispatcher.getInstance().schedule( self.CONFIG_TIMER_E, Event( self.EVENT_TIMER_E ), srcObj = self, dstObj = self )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:6,代碼來源:uac_transaction.py

示例9: inCompleted_onRequest

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def inCompleted_onRequest( self, event ):
		# Resend response to client.
		Dispatcher.getInstance().notify( self.lastResponse )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:5,代碼來源:uas_transaction.py

示例10: onRxResponse

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def onRxResponse( self, event ):
		Dispatcher.getInstance().send( event, srcObj = self, dstObj = self.transaction )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:4,代碼來源:uas_dialog_subscribe.py

示例11: onTxResponse

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def onTxResponse( self, event ):
		Dispatcher.getInstance().notify( event )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:4,代碼來源:uas_dialog_subscribe.py

示例12: inConfirmed_onSUBSCRIBE

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def inConfirmed_onSUBSCRIBE( self, event ):
		self.transaction = Transaction( event.message['Call-ID'], self, event )
		# Send request to server.
		Dispatcher.getInstance().send( event, srcObj = self, dstObj = self.transaction )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:6,代碼來源:uas_dialog_subscribe.py

示例13: onTxRequest

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def onTxRequest( self, event ):
		Dispatcher.getInstance().notify( event )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:4,代碼來源:uas_dialog_subscribe.py

示例14: inTrying_onTimerE

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def inTrying_onTimerE( self, event ):
		# Resend request to server.
		Dispatcher.getInstance().notify( self.request )

		# Restart Timer E.
		Dispatcher.getInstance().schedule( self.CONFIG_TIMER_E, Event( self.EVENT_TIMER_E ), srcObj = self, dstObj = self )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:8,代碼來源:uac_transaction.py

示例15: inProceeding_onRequest

# 需要導入模塊: from iron.dispatcher import Dispatcher [as 別名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 別名]
	def inProceeding_onRequest( self, event ):
		# Resend response to client.
		Dispatcher.getInstance().notify( self.lastResponse )
開發者ID:CaveMike,項目名稱:mercury,代碼行數:5,代碼來源:uas_transaction.py


注:本文中的iron.dispatcher.Dispatcher.getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。