Digging the code

5 views
Skip to first unread message

Konstantin Mirin

unread,
Oct 15, 2009, 2:24:04 PM10/15/09
to Comet Desktop
Hi all,

I'm impressed by the project itself and I want to join the project, so
I started studying the code.
I've downloaded the code from github, so I'll be referring to that
version. I have a few questions on it:
1) The code structure. Could anybody explain what is where? Where is
the desktop itself (JS part), where is the backend, how it is joined
together, where are entry points?
I found that all the main JS code is in the public/desktop/core. It
seems like my applications for this desktop should go to the /public/
desktop/js, right? And what is in the lib folder?
Is it possible to load JS files with applications after desktop is
started? I think it should be so :)
2) Messages/events structure. On the googlecode main page you have one
item in the "features":
> Hierarchical (channel based) PubSub interface. (Can tie into STOMP and other pubsubs)
Could you please explain how it works? I found that you subscribe to
custom events like /desktop/app/register' and others. You may fire
them and subscribe to *, which, I guess, means all events. But I'd
like to get some more information, starting from the basics - how this
is implemented, how it should be used, what are usecases and benefits
etc
3) Overall architecture. I studied only the core.js a bit, it seems
like you have your desktop as border layout within the Viewport with
north and south panels (top and bottom toolbars), which are actually
special components. I'm curious, how all that interacts altogether,
how window knows it should be minimized to the bottom bar etc. I want
to learn this in order to create the window management adapter that
should enable user switch between window management.
Description of the overall process flow would be very very helpful.
You may just give hints and I'll help with the complete docs.
It seems that there is not too much JS code there (or it seemed to me
so :)), so documenting it now should be a more easy process than in
the far future when it is finished :)

David Davis

unread,
Oct 22, 2009, 5:45:24 PM10/22/09
to comet-...@googlegroups.com
Sorry, for the delay.  I've been very busy.  My responses are intermixed below.

David Davis
☄ Software Engineer
http://xant.us/
http://xantus.tel/


On Thu, Oct 15, 2009 at 11:24, Konstantin Mirin <konstant...@gmail.com> wrote:

Hi all,

I'm impressed by the project itself and I want to join the project, so
I started studying the code.
I've downloaded the code from github, so I'll be referring to that
version. I have a few questions on it:
1) The code structure. Could anybody explain what is where? Where is
the desktop itself (JS part), where is the backend, how it is joined
together, where are entry points?

Currently all of the desktop js is in public/desktop/
The backend is everywhere else.  Static files are served out of public/
 
I found that all the main JS code is in the public/desktop/core. It
seems like my applications for this desktop should go to the /public/
desktop/js, right? And what is in the lib folder?

I've been putting mine in public/desktop/js/
 
Is it possible to load JS files with applications after desktop is
started? I think it should be so :)

Yes.  The CometDesktop.FileFetcher is in core/base.js.  As a temporary measure, I load all of the files from app.manifest (see core/base.js) after the login process.
Later, the manifest will come from the server after the login.
 
2) Messages/events structure. On the googlecode main page you have one
item in the "features":
> Hierarchical (channel based) PubSub interface. (Can tie into STOMP and other pubsubs)
Could you please explain how it works? I found that you subscribe to
custom events like /desktop/app/register' and others. You may fire
them and subscribe to *, which, I guess, means all events. But I'd
like to get some more information, starting from the basics - how this
is implemented, how it should be used, what are usecases and benefits
etc

(Just so everyone else knows, Comet Desktop on Google code is v1, and this version (v2) is on github.)

http://github.com/xantus/comet-desktop/blob/master/public/desktop/lib/Sprocket/PubSub.js

Observable is augmented to include the publish and subscribe methods, so anything that is a subclass of observable can pubsub.
For instance:

win = new Ext.Window({
  ....
});
win.subscribe( '/foo/bar', function( ev, channel ) {
   ....   
}, win );
win.publish( '/foo/bar', { test: 'hello world' } );

Channels are / separated, and should not include a trailing slash.
If there are two subscribers, one on /foo and the other on /foo/bar.  When an event is published to /foo/bar, it is delivered to the /foo/bar listener, then the /foo listener.
The 2nd param will always contain the actual channel published to (/foo/bar)

Now, this pubsub is client side only, but it does allow you to tie it to a server side pubsub by just republishing events received via ajax.

// a more complex example might queue the events, and use a delayed task
var app = new Ext.util.Observable();
app.subscribe( '/server', function( ev, channel ) {
    Ext.Ajax.request( ... );
});

I will have a more complex example using xmpp pubsub when I release the jabber/xmpp client.

 
3) Overall architecture. I studied only the core.js a bit, it seems
like you have your desktop as border layout within the Viewport with
north and south panels (top and bottom toolbars), which are actually
special components. I'm curious, how all that interacts altogether,
how window knows it should be minimized to the bottom bar etc. I want
to learn this in order to create the window management adapter that
should enable user switch between window management.

"Use the source, Luke."
 
Description of the overall process flow would be very very helpful.
You may just give hints and I'll help with the complete docs.
It seems that there is not too much JS code there (or it seemed to me
so :)), so documenting it now should be a more easy process than in
the far future when it is finished :)


A lot of the code is changing, so I have left documentation until a later time.
 


Reply all
Reply to author
Forward
0 new messages