本文整理汇总了Python中context.Context.queue方法的典型用法代码示例。如果您正苦于以下问题:Python Context.queue方法的具体用法?Python Context.queue怎么用?Python Context.queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.queue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runTest
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import queue [as 别名]
def runTest( self ):
context = Context( 'context' )
context.start()
listener = UacSubscriptionListener()
listener.context = context
subscription = UacSubscription( 'subscription0', listener, subscriptionSource='', user='chloe', resourceUri=Uri('bones', 'cave'), event='whats-to-eat', contentType=ContentType('food', 'xml'), expires=3600 )
context.queue( Event( subscription.EVENT_SUBSCRIBE ), subscription )
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 )
context.queue( e, subscription )
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 )
context.queue( e, subscription )
context.queue( Event( subscription.EVENT_UNSUBSCRIBE ), subscription )
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 )
context.queue( e, subscription )
sleep( 0.5 )
assert 1
示例2: runTest
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import queue [as 别名]
def runTest( self ):
context = Context( 'context' )
context.start()
listener = TestListener()
listener.context = context
node = System( 'system0', listener )
node.addListener( listener )
node.process( Event( 'Start' ) )
s = 'SUBSCRIBE sip:[email protected];treats SIP/2.0\r\nTo: "Matt"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nCall-ID: 12345\r\nCSeq: 16 SUBSCRIBE\r\n\r\n'
m = Message( s )
e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress=node.query( 'network.localAddress' ), localPort=node.query( 'network.localPort' ), remoteAddress=node.query( 'network.remoteAddress' ), remotePort=node.query( 'network.remotePort' ) )
context.queue( e, node )
sleep( 2 )
示例3: test
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import queue [as 别名]
def test(self):
events = [Event('event0'), Event('event1'), Event('event2')]
o = SampleObj(events)
c = Context('context0')
for event in events:
future = c.queue(event, o, o)
time.sleep(0.1)
c.poll()