本文整理汇总了Python中iron.dispatcher.Dispatcher.notify方法的典型用法代码示例。如果您正苦于以下问题:Python Dispatcher.notify方法的具体用法?Python Dispatcher.notify怎么用?Python Dispatcher.notify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iron.dispatcher.Dispatcher
的用法示例。
在下文中一共展示了Dispatcher.notify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runTest
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def runTest( self ):
c = Context( 'Root' )
c.start()
o0 = self.TestObj()
Dispatcher.add( obj=o0, parentObj=None, context=c )
o1 = self.TestObj()
Dispatcher.add( obj=o1, parentObj=None, context=c )
Dispatcher.addListener( srcObj=o1, dstObj=o0 )
Dispatcher.send( event=Event( '1' ), srcObj=o0, dstObj=o1 )
assert( str(o1.lastHandler) == 'on1' )
Dispatcher.queue( event=Event( '2' ), srcObj=o0, dstObj=o1 )
#assert( str(o1.lastHandler) == 'on2' )
Dispatcher.send( event=Event( '3' ), srcObj=o0, dstObj=o1 )
#assert( str(o1.lastHandler) == 'on3' )
Dispatcher.notify( event=Event( '4' ), srcObj=o1 )
#assert( str(o1.lastHandler) == 'on4' )
Dispatcher.notify( event=Event( '4' ), srcObj=o1 )
#assert( str(o1.lastHandler) == 'on4' )
c.stop()
示例2: inBound_onUnbind
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inBound_onUnbind( self, event ):
self.state = self.STATE_UNBINDING
self.socket.close()
self.socket = None
event.binding = self
self.state = self.STATE_UNBOUND
Dispatcher.notify( StateEvent( State.EVENT_STATE_CHANGE, self.state, self.STATE_BOUND ) )
示例3: inConnected_onUnbind
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inConnected_onUnbind( self, event ):
self.state = self.STATE_DISCONNECTING
self.socket.shutdown( SHUT_RDWR )
self.state = self.STATE_DISCONNECTED
newEvent = NetEvent( NetEvent.EVENT_DISCONNECTED, self.transport, self.localAddress, self.localPort, self.remoteAddress, self.remotePort, connection=self )
Dispatcher.notify( newEvent )
示例4: close
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def close( self, event ):
self.state = self.STATE_DISCONNECTING
self.socket.close()
self.socket = None
self.state = self.STATE_DISCONNECTED
newEvent = NetEvent( NetEvent.EVENT_DISCONNECTED, self.transport, self.localAddress, self.localPort, self.remoteAddress, self.remotePort, connection=self )
Dispatcher.notify( newEvent )
示例5: inInitial_onBind
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inInitial_onBind( self, event ):
self.state = self.STATE_BINDING
self.socket = socket( AF_INET, SOCK_DGRAM )
self.socket.setblocking( 0 )
self.socket.bind( ( self.localAddress, self.localPort ) )
self.socket.setsockopt( SOL_SOCKET, SO_REUSEADDR, 1 )
event.binding = self
self.state = self.STATE_BOUND
Dispatcher.notify( StateEvent( State.EVENT_STATE_CHANGE, self.state, self.STATE_INITIAL ) )
示例6: inBound_onRead
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inBound_onRead( self, event ):
if self.socket:
try:
buffer, source = self.socket.recvfrom( self.query( 'network.maxmessage' ), self.query( 'network.recvfromflags' ) )
self.log.info( 'recvfrom:\n%s(%s:%s %s:%s)\n%s.' % ( str(self.transport), str(self.localAddress), str(self.localPort), str(source[0]), str(source[1]), str(buffer) ) )
newEvent = NetEvent( NetEvent.EVENT_RX_PACKET, self.transport, self.localAddress, self.localPort, remoteAddress=source[0], remotePort=source[1], packet=str(buffer) )
Dispatcher.notify( newEvent )
except error, e:
newEvent = NetError( e[0], e[1], self.transport, self.localAddress, self.localPort )
Dispatcher.notify( newEvent )
示例7: inConnected_onRead
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inConnected_onRead( self, event ):
if self.socket:
buffer = self.socket.recv( self.query( 'network.maxmessage' ), self.query( 'network.recvflags' ) )
if buffer:
self.log.info( 'recv:\n%s(%s:%s %s:%s)\n%s.' % ( str(self.transport), str(self.localAddress), str(self.localPort), str(self.remoteAddress), str(self.remotePort), str(buffer) ) )
newEvent = NetEvent( NetEvent.EVENT_RX_PACKET, self.transport, self.localAddress, self.localPort, self.remoteAddress, self.remotePort, packet=str(buffer), connection=self )
Dispatcher.notify( newEvent )
else:
# Remote disconnect.
self.close( event )
示例8: inInitial_onBind
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inInitial_onBind( self, event ):
self.state = self.STATE_BINDING
#Dispatcher.notify( StateEvent( State.EVENT_STATE_CHANGE, self.state, self.STATE_INITIAL ) )
self.socket = socket( AF_INET, SOCK_STREAM )
self.socket.setblocking( 0 )
self.socket.bind( ( self.localAddress, self.localPort ) )
self.socket.setsockopt( SOL_SOCKET, SO_REUSEADDR, 1 )
self.socket.listen( self.query( 'network.maxconnections' ) )
event.binding = self
self.state = self.STATE_BOUND
Dispatcher.notify( StateEvent( State.EVENT_STATE_CHANGE, self.state, self.STATE_INITIAL ) )
示例9: inBound_onQueue
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inBound_onQueue( self, event ):
self.__queue.put( event )
self.remoteAddress = event.remoteAddress
self.remotePort = event.remotePort
#FIXME: self.socket.settimeout( self.query( 'network.connecttimeout' ) )
try:
self.socket.connect( (event.remoteAddress, event.remotePort) )
self.state = self.STATE_CONNECTING
return True
except error, e:
newEvent = NetError( e[0], e[1], self.transport, self.localAddress, self.localPort, connection=self )
Dispatcher.notify( newEvent )
self.close( event )
return False
示例10: onNetError
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def onNetError( self, event ):
Dispatcher.notify( event )
示例11: onDisconnected
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def onDisconnected( self, event ):
Dispatcher.notify( event )
示例12: onRxPacket
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def onRxPacket( self, event ):
Dispatcher.notify( event )
示例13: inBound_onError
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inBound_onError( self, event ):
error = self.socket.getsockopt( SOL_SOCKET, SO_ERROR )
Dispatcher.notify( NetError( error, None, self.transport, self.localAddress, self.localPort ) )
示例14: inConnected_onError
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inConnected_onError( self, event ):
error = self.socket.getsockopt( SOL_SOCKET, SO_ERROR )
Dispatcher.notify( NetError( error, None, self.transport, self.localAddress, self.localPort, self.remoteAddress, self.remotePort, connection=self ) )
self.close( event )
示例15: inBound_onDisconnected
# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
def inBound_onDisconnected( self, event ):
Dispatcher.notify( event )