本文整理汇总了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 )
示例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 ) )
示例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()
示例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()
示例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 )
示例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()
示例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
示例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 )
示例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 )
示例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 )
示例11: onTxResponse
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 别名]
def onTxResponse( self, event ):
Dispatcher.getInstance().notify( event )
示例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 )
示例13: onTxRequest
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import getInstance [as 别名]
def onTxRequest( self, event ):
Dispatcher.getInstance().notify( event )
示例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 )
示例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 )