[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.technology.ecf] Re: Starting a Chat Use Case
|
(note: newsgroup is acting funny .... seeing double posts. so apologies
if this appears twice, or if someone already answered John's question)
Here is my rough understanding of this from what I've read so far in the
javadoc and online documentation. Someone say something in if I'm wrong
here. Putting in "???" in unknown bits.
--- for user 1
// create a chat container - ignore what kind of protocols, etc for now
ISharedObjectContainer chatLobby =
SharedObjectContainerFactory.
makeSharedObjectContainer("chatLobby");
// set up listener for any messages sent to my container
chatLobby.addListener( ... );
// create a chat object, forget about transactional stuff for now
SharedObjectDescription chatObjectDescription = ...; // ???
ISharedObject user1 =
chatLobby.getSharedObjectManager().
createSharedObject(chatObjectDescription,null);
// put the chat object in the container associated with a given ID, and
// forget about properties and transactional for now
ID user1Id = IDFactory.makeGUID();
chatLobby.addSharedObject(user1Id,user1,null,null);
// need id where to "rendezvous" with user 2. lobbyInfo contains the
// details where to "meet" up on the chat service (e.g. a
// "public" channel)
Namespace chatLobbyNamespace = IDFactory.getNamespaceByName(...);
Object[] lobbyInfo = ...; // ???
ID chatLobbyId = IDFactory.makeID(chatLobbyNamespace,lobbyInfo);
// login
Object user1LoginData = ...; // authentication info
chatLobby.joinGroup(chatLobbyId,user1LoginData);
// just get the first member for now, assume it is a user
ID[] members = chatLobby.getSharedObjectIDs();
ID user2Id = members[0];
// find shared object associated with user2
ISharedObject user2 = chatLobby.getSharedObjectManager().
getSharedObject(user2Id);
// establish a 2-way messaging relationship between user1 and user2
chatLobby.connectSharedObject(user1Id,new ID[] {user2Id});
chatLobby.connectSharedObject(user2Id,new ID[] {user1Id});
// define a new container to hold the a 1-to-1 chat session
ISharedObjectContainer chatSession =
SharedObjectContainerFactory.
makeSharedObjectContainer("chatSession");
// add me into the session
chatSession.addSharedObject(user1Id,user1,null,null);
// and listen for any messages in this 1-to-1 session
chatSession.addListener(...);
// and make this available for only invited people to join in.
// any protections should be specified in invitationOnlyInfo?
Object[] chatSessionInfo = ...; // ???
ID chatSessionId = IDFactory.makeID(chatLobbyNamespace,chatSessionInfo);
Object invitationOnlyInfo = ...; // ???
chatSession.joinGroup(chatSessionId,invitationOnlyInfo);
// now prepare to invite user2...
// somehow get a ISharedObjectContext to use "sendMessage"
ISharedObjectContext lobbyContext = ...getConfig().getContext(); // ???
// send out the invitation in the "public" chatLobby
Object chatInvitationMessage = ...; // ???, pass along ID to chatSession
lobbyContext.createMessage(user2Id,chatInvitationMessage);
--- for user 2
// similar process like user 1 (log into a chat lobby) and
// then in the chatLobby listener defined by calling
// chatLobby.addListener(), check if an invitation message
// came through. the invite should hold chatSessionId so
// user 2 can do something like this
private void joinSession( ID chatSessionId )
{
ISharedObjectContainer chatSession =
SharedObjectContainerFactory.
makeSharedObjectContainer("chatSession");
// e.g. join info could might be a password if the chat room is
// protected
Object joinInfo = ...; // ???
chatSession.joinGroup(chatSessionId,joinInfo);
}
Several notes:
In this setup, there is a container for a "lobby", the public space to
discover other members. The lobby is where people can send invites, and
find out who's online (e.g. buddy list). Shared objects in the lobby
are really tokens for user presence : if user1's object is in the lobby,
then user1 is "online". Login is done via the join() method. Listing
who's online is done by listing what object IDs are in the "lobby"
container (after join() is called).
The lobby needs a unique ID for all users to connect to. This is done
by defining an ID via namespaces. IDFactory.getNamespace(...) would
define an appropriate namespace for IDFactory.makeID(...)
To start a chat, user1 creates another container for the 1-to-1 chat
session. join() here denotes creating a session for 1-to-1 access, so a
lot of this hinges upon the Object[] parameter in join()... this doesn't
feel quite right to me.
To invite user2, user1 sends a message to user2 in the lobby container
via a ISharedObjectContext... not sure how to get one of these context
objects. I don't see a ISharedObject.getContext() method. And
ISharedContainerObject.getConfig() doesn't return a ISharedObjectConfig
which has the needed getContext() method.
user2 would have to set up a listener in the lobby container for
invitation message types, and join the 1-to-1 chat session container by
calling join(). The ID of the chat session must be passed along in the
invitation message.
Does this sound right?
Li-Te
John F. Patterson wrote:
It would help me if we identified a few use cases and worked them
through using the API. The simplest is probably starting a chat. We
can worry later about actually using the chat. For now, I just want to
understand how it all gets started.
Normally, I think of chat as having three main steps to get it going:
1. One user initiates a chat session.
2. Somehow another user becomes informed of the existence of the chat
(the invite)
3. The second user joins the chat.
For step 1), I assume that I create a SharedContainer to correspond to
the chat session. Then I create a SharedObject that will be used to
accomplish the actual communication.
For step 2), I assume I must send the ID of the SharedContainer to the
other user. I don't believe the ECF provides an explicit way to do
this, but one could be invented on top of it.
For step 3), I assume the second user creates a SharedContainer of the
appropriate type (how do they know the type?) and Join the group
identified by the ID sent to them. Then somehow, they find the
SharedObject.
Do I have this right, as far as it goes? As you can see, I am a little
unclear on some of the specifics, particularly on how the SharedObjects
come to exist on the second machine. Are they brought into existence
upon joining the group? Does the second user learn about them via an
event?
I would find it helpful to see the code for this use case.