2009-08-20 22:57:24 +00:00
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Contributors can be viewed at:
|
|
|
|
|
http://svn.secondlife.com/svn/linden/projects/2008/pyogp/lib/base/trunk/CONTRIBUTORS.txt
|
|
|
|
|
|
|
|
|
|
$LicenseInfo:firstyear=2008&license=apachev2$
|
|
|
|
|
|
|
|
|
|
Copyright 2009, Linden Research, Inc.
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0.
|
|
|
|
|
You may obtain a copy of the License at:
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
or in
|
|
|
|
|
http://svn.secondlife.com/svn/linden/projects/2008/pyogp/lib/base/LICENSE.txt
|
|
|
|
|
|
|
|
|
|
$/LicenseInfo$
|
|
|
|
|
"""
|
|
|
|
|
|
2009-03-03 01:40:52 +00:00
|
|
|
PacketHandler
|
2009-04-27 22:48:01 +00:00
|
|
|
~~~~~~~~~~~~~
|
2009-03-03 01:40:52 +00:00
|
|
|
|
|
|
|
|
The basic packet handling event/callbackcase
|
2009-04-27 22:48:01 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2009-03-03 01:40:52 +00:00
|
|
|
|
|
|
|
|
First, initialize the packet handler
|
2009-06-05 21:02:59 +00:00
|
|
|
>>> from pyogp.lib.base.message.message_handler import MessageHandler
|
|
|
|
|
>>> message_handler = MessageHandler()
|
2009-03-03 01:40:52 +00:00
|
|
|
|
|
|
|
|
How about a mock callback handler
|
|
|
|
|
>>> def callback(packet): print packet
|
|
|
|
|
|
2009-06-05 22:22:13 +00:00
|
|
|
>>> onStartPingCheck_received = message_handler.register("StartPingCheck")
|
2009-03-03 01:40:52 +00:00
|
|
|
>>> onStartPingCheck_received.subscribe(callback)
|
|
|
|
|
|
|
|
|
|
Stage a packet
|
2009-06-05 21:02:59 +00:00
|
|
|
>>> from pyogp.lib.base.message.message import Message
|
|
|
|
|
>>> packet = Message('StartPingCheck')
|
2009-03-03 01:40:52 +00:00
|
|
|
|
|
|
|
|
Fire the event, it returns a packet
|
|
|
|
|
Unpossible to include this in the test, the memory ref keeps changing
|
|
|
|
|
But, you get the idea...
|
2009-07-15 17:25:34 +00:00
|
|
|
event_data = message_handler.handle(packet)
|
2009-06-05 21:02:59 +00:00
|
|
|
<pyogp.lib.base.message.message.Message object at 0x14da450>
|
2009-03-03 01:40:52 +00:00
|
|
|
|