Revamped chat handling a bit:

- the ChatProvider is now a proper singleton rather than providing static
methods for everything (it is accessed through CrowdServer.chatprov)
- it can now be extended to create a custom UserMessage for tells (which can
contain avatar information on systems that want to show an avatar on the
receipt of a tell)
- the ChatProvider API was tidied up a bit as some methods had been addded over
time that were not sufficiently general purpose so their callers will be
changed to use the general purpose APIs.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4251 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-07-06 00:22:12 +00:00
parent ef86404ed8
commit 05cef39f63
7 changed files with 117 additions and 110 deletions
@@ -27,6 +27,7 @@ import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService;
import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.UserMessage;
/**
* Bridges certain Crowd services between peers in a cluster configuration.
@@ -37,6 +38,6 @@ public interface CrowdPeerService extends InvocationService
* Used to forward a tell request to the server on which the destination
* user actually occupies.
*/
public void deliverTell (Client client, Name teller, Name target,
String message, ChatService.TellListener listener);
public void deliverTell (Client client, UserMessage message, Name target,
ChatService.TellListener listener);
}
@@ -23,6 +23,7 @@ package com.threerings.crowd.peer.data;
import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.ChatMarshaller;
import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.peer.client.CrowdPeerService;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.InvocationMarshaller;
@@ -43,12 +44,12 @@ public class CrowdPeerMarshaller extends InvocationMarshaller
public static final int DELIVER_TELL = 1;
// documentation inherited from interface
public void deliverTell (Client arg1, Name arg2, Name arg3, String arg4, ChatService.TellListener arg5)
public void deliverTell (Client arg1, UserMessage arg2, Name arg3, ChatService.TellListener arg4)
{
ChatMarshaller.TellMarshaller listener5 = new ChatMarshaller.TellMarshaller();
listener5.listener = arg5;
ChatMarshaller.TellMarshaller listener4 = new ChatMarshaller.TellMarshaller();
listener4.listener = arg4;
sendRequest(arg1, DELIVER_TELL, new Object[] {
arg2, arg3, arg4, listener5
arg2, arg3, listener4
});
}
@@ -23,6 +23,7 @@ package com.threerings.crowd.peer.server;
import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.ChatMarshaller;
import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.peer.client.CrowdPeerService;
import com.threerings.crowd.peer.data.CrowdPeerMarshaller;
import com.threerings.presents.client.Client;
@@ -61,7 +62,7 @@ public class CrowdPeerDispatcher extends InvocationDispatcher
case CrowdPeerMarshaller.DELIVER_TELL:
((CrowdPeerProvider)provider).deliverTell(
source,
(Name)args[0], (Name)args[1], (String)args[2], (ChatService.TellListener)args[3]
(UserMessage)args[0], (Name)args[1], (ChatService.TellListener)args[2]
);
return;
@@ -37,6 +37,7 @@ import com.threerings.presents.peer.server.PeerManager;
import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.ChatMessage;
import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.chat.server.ChatProvider;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.server.CrowdServer;
@@ -62,17 +63,16 @@ public class CrowdPeerManager extends PeerManager
}
// documentation inherited from interface CrowdPeerProvider
public void deliverTell (ClientObject caller, Name teller, Name target,
String message, ChatService.TellListener listener)
public void deliverTell (ClientObject caller, UserMessage message,
Name target, ChatService.TellListener listener)
throws InvocationException
{
// the originating server has already permissions checked the teller,
// so we just forward the message as if it originated on this server
ChatProvider.deliverTell(teller, target, message, listener);
// we just forward the message as if it originated on this server
CrowdServer.chatprov.deliverTell(message, target, listener);
}
// documentation inherited from interface ChatProvider.TellForwarder
public boolean forwardTell (Name teller, Name target, String message,
public boolean forwardTell (UserMessage message, Name target,
ChatService.TellListener listener)
{
// look through our peer objects to see if the target user is online on
@@ -82,7 +82,7 @@ public class CrowdPeerManager extends PeerManager
CrowdClientInfo cinfo = (CrowdClientInfo)cnobj.clients.get(target);
if (cinfo != null) {
cnobj.crowdPeerService.deliverTell(
peer.getClient(), teller, target, message, listener);
peer.getClient(), message, target, listener);
return true;
}
}
@@ -101,7 +101,7 @@ public class CrowdPeerManager extends PeerManager
}
// clear our tell forwarder registration
ChatProvider.setTellForwarder(null);
CrowdServer.chatprov.setTellForwarder(null);
}
@Override // documentation inherited
@@ -116,7 +116,7 @@ public class CrowdPeerManager extends PeerManager
new CrowdPeerDispatcher(this), false));
// register ourselves as a tell forwarder
ChatProvider.setTellForwarder(this);
CrowdServer.chatprov.setTellForwarder(this);
}
@Override // documentation inherited
@@ -23,6 +23,7 @@ package com.threerings.crowd.peer.server;
import com.threerings.crowd.chat.client.ChatService;
import com.threerings.crowd.chat.data.ChatMarshaller;
import com.threerings.crowd.chat.data.UserMessage;
import com.threerings.crowd.peer.client.CrowdPeerService;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.ClientObject;
@@ -38,6 +39,6 @@ public interface CrowdPeerProvider extends InvocationProvider
/**
* Handles a {@link CrowdPeerService#deliverTell} request.
*/
public void deliverTell (ClientObject caller, Name arg1, Name arg2, String arg3, ChatService.TellListener arg4)
public void deliverTell (ClientObject caller, UserMessage arg1, Name arg2, ChatService.TellListener arg3)
throws InvocationException;
}