pub/sub PHP implementation as discussed in earlier thread

9 views
Skip to first unread message

Jon Hinson

unread,
Nov 19, 2007, 2:00:35 PM11/19/07
to Orbited Discussion
I decided to start a new thread about this as I didn't want to hijack
the other thread. Dionysis, I would definitely like to hear more about
your PHP project over this. Here's the jist of what I'm trying to
implement. Each user can open up as many "conversations" as he wants,
and each coversation can have up to 10 people in them. The way I
thought of solving this was each person opens up a long polling
connection with their userid and they just connect to session 0. When
someone creates or joins a conversation, an entry is made into a db
table with their userid and the convo_id. (handled by the php script)
then, each time an event is made( send msg, join, leave), the user
passes in there convo_id, the php script gets all of the users who are
in that convo and passes that list to orbited along with some type of
json object with the convo I'd, event type, MSG, etc. The client can
then handle what to do with each event( which convo to update, how to
update it, etc)

Keep in mind, ive never worked on or developed a web app that required
multiple servers, so I don't know what additional things I would have
to implement with this method, or if it would work at all. Also, I'm
writing this as Im driving home from college,so my thoughts may seem
rambled. Please feel free to comment, critique, correct, etc anything
about my method.

Jon Hinson

Dionysis Zindros

unread,
Nov 19, 2007, 3:15:19 PM11/19/07
to orbite...@googlegroups.com
Hi Jon,

My PHP framework I'm developing for Orbited (called "Callisto") is a
generalized pub/sub framework. This means it allows any kind of data
to be published and users to subscribe as they wish accordingly.

The basic idea is: Each user subscribes to a channel (identified by a
string) and opens up a single HTTP polling connection. Then your PHP
application publishes data to all the users of a particular channel
(again identifying it with the same string). The subscription is
passed through the PHP script, so it can handle authentication and
other issues. Data is stored in MySQL using a table for all
subscriptions (but not for channels).

I hope I can publish the source code of the framework as I'm done with
this, hopefully you'll be able to use it as a base for your chatting
system as well, it sounds a very fitting application.

Dionysis.

Jacob Rus

unread,
Nov 26, 2007, 6:34:28 PM11/26/07
to orbite...@googlegroups.com
Dionysis Zindros wrote:
> My PHP framework I'm developing for Orbited (called "Callisto") is a
> generalized pub/sub framework. This means it allows any kind of data
> to be published and users to subscribe as they wish accordingly.
>
> The basic idea is: Each user subscribes to a channel (identified by a
> string) and opens up a single HTTP polling connection. Then your PHP
> application publishes data to all the users of a particular channel
> (again identifying it with the same string). The subscription is
> passed through the PHP script, so it can handle authentication and
> other issues. Data is stored in MySQL using a table for all
> subscriptions (but not for channels).
>
> I hope I can publish the source code of the framework as I'm done with
> this, hopefully you'll be able to use it as a base for your chatting
> system as well, it sounds a very fitting application.

Sounds neat! keep us posted as you make progress. :)

-Jacob

Michael Carter

unread,
Dec 27, 2007, 4:17:10 AM12/27/07
to Orbited Discussion
Just wanted to chime in that the latest Orbited 0.3.0 now ships with
revolved which is a pub/sub implementation on top of orbited and
includes replication between nodes. By all means continue your work on
the php version, but keep this alternative in mind as well.

-Michael Carter

Dionysis Zindros

unread,
Dec 27, 2007, 4:43:36 AM12/27/07
to orbite...@googlegroups.com
Thanks, I'll check it out! :)

Michael Carter

unread,
Dec 27, 2007, 4:55:30 AM12/27/07
to orbite...@googlegroups.com
Quick tutorial

1) Visit http://127.0.0.1:8000/_/revolved/manage/
2) Click start
3) turn on firebug
4) Visit http://127.0.0.1:8000/_/revolved/static/test.html
in the firebug console:
5) Revolved.connect("127.0.0.1", 8000)
6)
Revolved.authenticate("random_guest")
7)
eventcb = function(channel, sender, payload) { console.log([channel, sender, payload]) }
8)
Revolved.subscribe("foo", eventcb)
9)
Revolved.publish("foo", ["some", 5, "data"])


And thats the basics. Anyone who wants to chat with me and help write a real tutorial, feel free to step up.

-Michael Carter
Reply all
Reply to author
Forward
0 new messages