diff options
author | Rafael Ortiz <rafael@activitycentral.com> | 2012-03-29 20:12:25 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2012-03-29 20:12:25 (GMT) |
commit | 840c7b75c705758c6b78acd0a76258ca775088a8 (patch) | |
tree | 4090b5124fd7f02adbbd6ce299adde104d4aba06 | |
parent | a63dcf50f59536a86b8c799a6b19a9d8dc32fff4 (diff) |
various trailling whitespaces removed
-rw-r--r-- | olpcgames/mesh.py | 105 |
1 files changed, 51 insertions, 54 deletions
diff --git a/olpcgames/mesh.py b/olpcgames/mesh.py index 1818214..24fd90b 100644 --- a/olpcgames/mesh.py +++ b/olpcgames/mesh.py @@ -1,86 +1,83 @@ '''Utilities for wrapping the telepathy network for Pygame -The 'mesh' module allows your Pygame game to be Shared +The 'mesh' module allows your Pygame game to be Shared across the OLPC networking infrastructure (D-bus and Tubes). It offers a simplified view of the Telepathy system. -All Sugar activities have a 'Share' menu (toolbar) which is -intended to allow other people to join the activity instance -and collaborate with you. When you select Share, the activity's +All Sugar activities have a 'Share' menu (toolbar) which is +intended to allow other people to join the activity instance +and collaborate with you. When you select Share, the activity's icon appears on the Neighborhood view of other laptops. -If you do nothing else with networking, this is all that will -happen: if anyone selects your shared activity icon, they will -just spawn a new instance of the activity, and they will get to +If you do nothing else with networking, this is all that will +happen: if anyone selects your shared activity icon, they will +just spawn a new instance of the activity, and they will get to play your game alone. -The mesh module automatically sets up a connection from each +The mesh module automatically sets up a connection from each participant to every other participant. It provides (string based) -communications channels that let you either broadcast messages +communications channels that let you either broadcast messages to other users or communicate point-to-point to one other user. -You can use the "handles" which uniquely idenify users to send -messages to an individual user (send_to( handle, message )) or +You can use the "handles" which uniquely idenify users to send +messages to an individual user (send_to( handle, message )) or broadcast( message ) to send a message to all participants. -More advanced (structured) networking can be handled by using -the get_object( handle, path ) function, which looks up an object -(by DBUS path) shared by the user "handle" and returns a -DBUS/Telepathy proxy for that object. The object you get back is -actually an olpcgames.dbusproxy.DBUSProxy instance, which -enforces asynchronous operations and runs your +More advanced (structured) networking can be handled by using +the get_object( handle, path ) function, which looks up an object +(by DBUS path) shared by the user "handle" and returns a +DBUS/Telepathy proxy for that object. The object you get back is +actually an olpcgames.dbusproxy.DBUSProxy instance, which +enforces asynchronous operations and runs your reply_handler/error_handler in the Pygame event loop. NOTE: - You *cannot* make synchronous calls on these objects! - You must use the named arguments: + You *cannot* make synchronous calls on these objects! + You must use the named arguments: + + reply_handler, error_handler - reply_handler, error_handler - - for every call which you perform on a shared object (normally + for every call which you perform on a shared object (normally these are ExportedGObject instances). -If you want to run your callbacks in the GTK event loop (for instance -because they need to handle GTK-side objects), you can use the -dbus_get_object function. This is *not* recommended for normal -usage, as any call to Pygame operations within the GTK event loop +If you want to run your callbacks in the GTK event loop (for instance +because they need to handle GTK-side objects), you can use the +dbus_get_object function. This is *not* recommended for normal +usage, as any call to Pygame operations within the GTK event loop can cause a segfault/core of your entire Activity. Note: - - mesh sets up N**2 connections for each shared activity, obviously - that will not scale to very large shared activities. + mesh sets up N**2 connections for each shared activity, obviously + that will not scale to very large shared activities. Note: - - The intention is that mesh will be refactored, possibly as a - new module called "olpcgames.network", which would break out - the various components so that there is no longer an assumed - networking layout. We will attempt to retain the mesh module's - API as we do so. + The intention is that mesh will be refactored, possibly as a + new module called "olpcgames.network", which would break out + the various components so that there is no longer an assumed + networking layout. We will attempt to retain the mesh module's + API as we do so. Events produced: - - olpcgames.CONNECT -- The tube connection was started. (i.e., the - user clicked Share or started the activity from the Neighborhood + + olpcgames.CONNECT -- The tube connection was started. (i.e., the + user clicked Share or started the activity from the Neighborhood screen). Event properties: - - id -- a unique identifier for this connection. (shouldn't be needed + + id -- a unique identifier for this connection. (shouldn't be needed for anything) - olpcgames.PARTICIPANT_ADD -- A participant joined the activity. - This will trigger for the local user as well as any arriving remote - users. Note that this *only* occurs after the activity is shared, - that is, the local user does not appear until after they have - shared a locally-started activity. + olpcgames.PARTICIPANT_ADD -- A participant joined the activity. + This will trigger for the local user as well as any arriving remote + users. Note that this *only* occurs after the activity is shared, + that is, the local user does not appear until after they have + shared a locally-started activity. Event properties: - - handle -- the arriving user's handle (a uniquely identifying string - assigned to the user by the Telepathy system, not human - readable), see lookup_buddy to retrieve human-readable + handle -- the arriving user's handle (a uniquely identifying string + assigned to the user by the Telepathy system, not human + readable), see lookup_buddy to retrieve human-readable descriptions of the user. olpcgames.PARTICIPANT_REMOVE -- A participant quit the activity. @@ -105,9 +102,9 @@ Events produced: Note: - Eventually we will stop using top-level Pygame event types for the - various networking message types (currently four of them). We will - likely use UserEvent with a sub-type specifier for the various events + Eventually we will stop using top-level Pygame event types for the + various networking message types (currently four of them). We will + likely use UserEvent with a sub-type specifier for the various events that OLPCGames produces. See Also: @@ -116,7 +113,7 @@ See Also: the mesh module and raw Telepathy (ExportedGObject instances) ''' import logging -log = logging.getLogger( 'olpcgames.mesh' ) +log = logging.getLogger('olpcgames.mesh') ##log.setLevel( logging.DEBUG ) import olpcgames from olpcgames.util import get_traceback @@ -141,7 +138,7 @@ except Exception, err: pass import pygame.event as PEvent -class OfflineError( Exception ): +class OfflineError(Exception): """Raised when we cannot complete an operation due to being offline""" DBUS_IFACE="org.laptop.games.pygame" |