com.threerings.crowd.chat.server
Class ChatProvider

java.lang.Object
  extended by com.threerings.crowd.chat.server.ChatProvider
All Implemented Interfaces:
InvocationProvider

public class ChatProvider
extends Object
implements InvocationProvider

The chat provider handles the server side of the chat-related invocation services.


Nested Class Summary
static interface ChatProvider.ChatForwarder
          Used to forward certain types of chat messages between servers in a multi-server setup.
static interface ChatProvider.TellAutoResponder
          Interface to allow an auto response to a tell message.
 
Field Summary
protected  ChatProvider.TellAutoResponder _autoRespond
          Generates auto-responses to tells.
protected  DObject _broadcastObject
          An alternative object to which broadcasts should be sent.
protected  ChatProvider.ChatForwarder _chatForwarder
          Forwards chat between servers.
protected  BodyLocator _locator
          Used to look up body objects by name.
protected  PlaceRegistry _plreg
          Provides access to place managers.
 
Constructor Summary
ChatProvider(InvocationManager invmgr)
          Creates and registers this chat provider.
 
Method Summary
 void away(ClientObject caller, String message)
          Processes a ChatService.away(java.lang.String) request.
 void broadcast(ClientObject caller, String message, InvocationService.InvocationListener listener)
          Processes a ChatService.broadcast(java.lang.String, com.threerings.presents.client.InvocationService.InvocationListener) request.
 void broadcast(Name from, byte levelOrMode, String bundle, String msg, boolean forward)
          Broadcast with support for a customizable level or mode.
 void broadcast(Name from, String bundle, String msg, boolean attention, boolean forward)
          Broadcasts the specified message to all place objects in the system.
protected  void broadcastTo(DObject object, Name from, byte levelOrMode, String bundle, String msg)
          Direct a broadcast to the specified object.
protected  UserMessage createTellMessage(BodyObject source, String message)
          Used to create a UserMessage for the supplied sender.
 void deliverTell(BodyObject target, UserMessage message)
          Delivers a tell notification to the specified target player.
 void deliverTell(UserMessage message, Name target, ChatService.TellListener listener)
          Delivers a tell message to the specified target and notifies the supplied listener of the result.
 void setAlternateBroadcastObject(DObject object)
          Set an object to which all broadcasts should be sent, rather than iterating over the place objects and sending to each of them.
 void setChatForwarder(ChatProvider.ChatForwarder forwarder)
          Configures the chat forwarder.
 void setTellAutoResponder(ChatProvider.TellAutoResponder autoRespond)
          Set the auto tell responder for the chat provider.
 void tell(ClientObject caller, Name target, String message, ChatService.TellListener listener)
          Processes a ChatService.tell(com.threerings.util.Name, java.lang.String, com.threerings.crowd.chat.client.ChatService.TellListener) request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_plreg

@Inject
protected PlaceRegistry _plreg
Provides access to place managers.


_locator

@Inject
protected BodyLocator _locator
Used to look up body objects by name.


_autoRespond

protected ChatProvider.TellAutoResponder _autoRespond
Generates auto-responses to tells. May be null.


_chatForwarder

protected ChatProvider.ChatForwarder _chatForwarder
Forwards chat between servers. May be null.


_broadcastObject

protected DObject _broadcastObject
An alternative object to which broadcasts should be sent.

Constructor Detail

ChatProvider

@Inject
public ChatProvider(InvocationManager invmgr)
Creates and registers this chat provider.

Method Detail

setAlternateBroadcastObject

public void setAlternateBroadcastObject(DObject object)
Set an object to which all broadcasts should be sent, rather than iterating over the place objects and sending to each of them.

Parameters:
object - an object to send all broadcasts, or null to send to each place object instead.

setTellAutoResponder

public void setTellAutoResponder(ChatProvider.TellAutoResponder autoRespond)
Set the auto tell responder for the chat provider. Only one auto responder is allowed. Note: this only works for same-server tells. If the tell is forwarded to another server, no auto-response opportunity is provided (because we never have both body objects in the same place).


setChatForwarder

public void setChatForwarder(ChatProvider.ChatForwarder forwarder)
Configures the chat forwarder. This is used by the Crowd peer services to forward messages between servers in a multi-server cluster.


tell

public void tell(ClientObject caller,
                 Name target,
                 String message,
                 ChatService.TellListener listener)
          throws InvocationException
Processes a ChatService.tell(com.threerings.util.Name, java.lang.String, com.threerings.crowd.chat.client.ChatService.TellListener) request.

Throws:
InvocationException

broadcast

public void broadcast(ClientObject caller,
                      String message,
                      InvocationService.InvocationListener listener)
               throws InvocationException
Processes a ChatService.broadcast(java.lang.String, com.threerings.presents.client.InvocationService.InvocationListener) request.

Throws:
InvocationException

away

public void away(ClientObject caller,
                 String message)
Processes a ChatService.away(java.lang.String) request.


broadcast

public void broadcast(Name from,
                      String bundle,
                      String msg,
                      boolean attention,
                      boolean forward)
Broadcasts the specified message to all place objects in the system.

Parameters:
from - the user the broadcast is from, or null to send the message as a system message.
bundle - the bundle, or null if the message needs no translation.
msg - the content of the message to broadcast.
attention - if true, the message is sent as ATTENTION level, otherwise as INFO. Ignored if from is non-null.
forward - if true, forward this broadcast on to any registered chat forwarder, if false, deliver it only locally on this server.

broadcast

public void broadcast(Name from,
                      byte levelOrMode,
                      String bundle,
                      String msg,
                      boolean forward)
Broadcast with support for a customizable level or mode.

Parameters:
levelOrMode - if from is null, it's an attentionLevel, else it's a mode code.

deliverTell

public void deliverTell(UserMessage message,
                        Name target,
                        ChatService.TellListener listener)
                 throws InvocationException
Delivers a tell message to the specified target and notifies the supplied listener of the result. It is assumed that the teller has already been permissions checked.

Throws:
InvocationException

deliverTell

public void deliverTell(BodyObject target,
                        UserMessage message)
Delivers a tell notification to the specified target player. It is assumed that the message is coming from some server entity and need not be permissions checked or notified of the result.


createTellMessage

protected UserMessage createTellMessage(BodyObject source,
                                        String message)
Used to create a UserMessage for the supplied sender.


broadcastTo

protected void broadcastTo(DObject object,
                           Name from,
                           byte levelOrMode,
                           String bundle,
                           String msg)
Direct a broadcast to the specified object.