I put a lot of thought into how XMPP should be integrated with PySoy's API,
this email is a first draft for how it could all work together.  All the
names here that don't exist yet are just ideas, please suggest better ones.
Think of use cases where this wouldn't work, or would make certain common
game UI designs prohibitively difficult.

I've thought of the following basic components:
 * roster (buddy list)
 * private chats
 * room chats (MUCs)
 * voice session (Jingle>ICE-RTP>Speex)
 * video stream (Jingle>ICE-RTP>Theora)
 * network games (Jingle>ICE-UDP)

For voice we'll have soy.audio.Voice, for video soy.textures.Video which
already exists, both will work as Transports which I'll explain further
below.

The rest present a set of inter-related questions, such as:
 * which soy.* module do they belong
 * what form of data do they represent
 * how are they setup and managed in a simple, Pythonic way

Here's the rough proposal for achieving this:

*soy.widgets.Roster* is a generic (not XMPP specific) widget that has "buddy
list" functionality.  It works like a dict and may contain instances of
soy.widgets.Roster as values (for groups).  This is used for the "buddy
list", for chat room occupants, perhaps even music tracks grouped by artist.

*soy.widgets.Messages* is a generic (not XMPP specific) widget that has
"chat window" functionality.  It contains a list-like FIFO buffer of strings
which can be .append'ed to and automatically removes the oldest message when
the buffer is full.  Color is achieved using Pango markup (
http://library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html) and
word wrap is handled internally using Pango for text layout.
*
soy.widgets.TextInput* is a generic widget for inputting chat text.  It has
an soy.action associated with hitting "enter" and optionally font, size,
style, color, etc can be added above this (displaying and outputting as
Pango markup, which is mostly what we send via XMPP anyway).

*soy.widgets.ChatBox* is a XMPP-specific container widget including a *
soy.widgets.Messages*, *soy.widgets.TextInput*, and potentially a *
soy.widgets.Roster* (for room occupants).  Instances of this class are
created as children of the XMPP instance they belong to.

That's the UI side of things, now;

*soy.transports.XMPP* is a single XMPP instance.  Like other transports,
it's used to interface soy instances to data storage or communication (ie,
streaming a video over HTTP creates a soy.textures.Video object).  Init'ing
an instance of this class logs in and creates a *soy.widgets.Roster* object
with the key "roster" automatically.  Thus, the following code would open a
new window containing just the buddy list:

*import soy
win = soy.windows.Window('Buddy List')
with xmpp = soy.transports.XMPP('[email protected]') :
  win.append(xmpp['roster'])
*
The "chats" key contains a *soy.widgets.Tabbed* of currently active chats
you have open, the value of each of these is an instance of *
soy.widgets.ChatBox* including an instance of *soy.widgets.Messages*, *
soy.widgets.TextInput*, and if a MUC a *soy.widgets.Roster*.

Thus, to create a basic IM client with PySoy with one window containing a
buddy list and tabbed chat window:

*import soy
win = soy.windows.Window('Buddy List')
stx = soy.widgets.StackX()
win.append(stx)
with xmpp = soy.transports.XMPP('[email protected]') :
  stx.append(xmpp['roster'])
  stx.append(xmpp['chats'])
*
If you wanted to do something different, such as having chat text appear
over avatar's heads, you could treat xmpp['chats'] as a dict and use the
[-1] of the messages contained.  In most cases such chat shouldn't be over
XMPP anyways since you'd want more server control over how things are
displayed.

What about voice and video chat?  These are ICE-RTP sessions, out-of-band of
XMPP, but always initiated by XMPP.  Both of these will be added to the
appropriate *soy.widgets.ChatBox* as well, the audio directly, the video to
a *soy.widgets.Canvas* to the left of the *soy.widgets.Messages*.  Of course
audio and textures are multi-use objects, so the video feed could be used
elsewhere too.

Lastly, initiating an actual game.  Just like voice and video, all
soy.networks will be initiated by XMPP.  You're either running an instance
of *soy.networks.Server* and announce this via XMPP or are joining a server
with an instance of *soy.networks.Client*.  These are a topic for another
email, what's important here is that they are parented to an XMPP transport
object.

Comments?
_______________________________________________
PySoy-Dev mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-dev

Reply via email to