当前位置: 首页>>代码示例>>Python>>正文


Python Dispatcher.notify方法代码示例

本文整理汇总了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()
开发者ID:,项目名称:,代码行数:28,代码来源:

示例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 ) )
开发者ID:CaveMike,项目名称:mercury,代码行数:11,代码来源:udp_binding.py

示例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 )
开发者ID:CaveMike,项目名称:mercury,代码行数:11,代码来源:tcp_binding.py

示例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 )
开发者ID:CaveMike,项目名称:mercury,代码行数:12,代码来源:tcp_binding.py

示例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 ) )
开发者ID:CaveMike,项目名称:mercury,代码行数:13,代码来源:udp_binding.py

示例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 )
开发者ID:CaveMike,项目名称:mercury,代码行数:13,代码来源:udp_binding.py

示例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 )
开发者ID:CaveMike,项目名称:mercury,代码行数:13,代码来源:tcp_binding.py

示例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 ) )
开发者ID:CaveMike,项目名称:mercury,代码行数:15,代码来源:tcp_binding.py

示例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
开发者ID:CaveMike,项目名称:mercury,代码行数:21,代码来源:tcp_binding.py

示例10: onNetError

# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
	def onNetError( self, event ):
		Dispatcher.notify( event )
开发者ID:CaveMike,项目名称:mercury,代码行数:4,代码来源:network.py

示例11: onDisconnected

# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
	def onDisconnected( self, event ):
		Dispatcher.notify( event )
开发者ID:CaveMike,项目名称:mercury,代码行数:4,代码来源:network.py

示例12: onRxPacket

# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
	def onRxPacket( self, event ):
		Dispatcher.notify( event )
开发者ID:CaveMike,项目名称:mercury,代码行数:4,代码来源:network.py

示例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 ) )
开发者ID:CaveMike,项目名称:mercury,代码行数:5,代码来源:udp_binding.py

示例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 )
开发者ID:CaveMike,项目名称:mercury,代码行数:7,代码来源:tcp_binding.py

示例15: inBound_onDisconnected

# 需要导入模块: from iron.dispatcher import Dispatcher [as 别名]
# 或者: from iron.dispatcher.Dispatcher import notify [as 别名]
	def inBound_onDisconnected( self, event ):
		Dispatcher.notify( event )
开发者ID:CaveMike,项目名称:mercury,代码行数:4,代码来源:tcp_binding.py


注:本文中的iron.dispatcher.Dispatcher.notify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。