當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。