diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index 51ecb00cf..6b7c39ece 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -1,5 +1,5 @@ // -// $Id: ChatDirector.java,v 1.57 2004/02/25 14:41:47 mdb Exp $ +// $Id: ChatDirector.java,v 1.58 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.client; @@ -20,6 +20,7 @@ import com.threerings.presents.dobj.MessageListener; import com.threerings.util.MessageBundle; import com.threerings.util.MessageManager; +import com.threerings.util.Name; import com.threerings.util.TimeUtil; import com.threerings.crowd.Log; @@ -63,7 +64,7 @@ public class ChatDirector extends BasicDirector /** * Returns whether the username may be added to the chatters list. */ - public boolean isChatterValid (String username); + public boolean isChatterValid (Name username); } /** @@ -152,7 +153,7 @@ public class ChatDirector extends BasicDirector /** * Adds a chatter to our list of recent chatters. */ - protected void addChatter (String name) + protected void addChatter (Name name) { // check to see if the chatter validator approves.. if ((_chatterValidator != null) && @@ -351,8 +352,8 @@ public class ChatDirector extends BasicDirector * @param rl an optional result listener if you'd like to be notified * of success or failure. */ - public void requestTell ( - final String target, String msg, final ResultListener rl) + public void requestTell (final Name target, String msg, + final ResultListener rl) { // make sure they can say what they want to say final String message = filter(msg, target, true); @@ -502,13 +503,13 @@ public class ChatDirector extends BasicDirector // if the message came from a user, make sure we want to hear it if (msg instanceof UserMessage) { UserMessage umsg = (UserMessage)msg; - String speaker = umsg.speaker; - message = filter(message, speaker, false); - if (message == null) { + Name speaker = umsg.speaker; + if ((message = filter(message, speaker, false)) == null) { return; + } - } else if (USER_CHAT_TYPE.equals(localtype) && - umsg.mode == ChatCodes.DEFAULT_MODE) { + if (USER_CHAT_TYPE.equals(localtype) && + umsg.mode == ChatCodes.DEFAULT_MODE) { // if it was a tell, add the speaker as a chatter addChatter(speaker); @@ -529,7 +530,7 @@ public class ChatDirector extends BasicDirector // if we auto-responded, report as much if (autoResponse != null) { - String teller = ((UserMessage) msg).speaker; + Name teller = ((UserMessage) msg).speaker; String amsg = MessageBundle.tcompose( "m.auto_responded", teller, autoResponse); displayFeedback(_bundle, amsg); @@ -630,7 +631,7 @@ public class ChatDirector extends BasicDirector /** * Run a message through all the currently registered filters. */ - public String filter (String msg, String otherUser, boolean outgoing) + public String filter (String msg, Name otherUser, boolean outgoing) { _filterMessageOp.setMessage(msg, otherUser, outgoing); _filters.apply(_filterMessageOp); @@ -643,7 +644,7 @@ public class ChatDirector extends BasicDirector */ protected static class FilterMessageOp implements ObserverList.ObserverOp { - public void setMessage (String msg, String otherUser, boolean outgoing) + public void setMessage (String msg, Name otherUser, boolean outgoing) { _msg = msg; _otherUser = otherUser; @@ -663,7 +664,7 @@ public class ChatDirector extends BasicDirector return _msg; } - protected String _otherUser; + protected Name _otherUser; protected String _msg; protected boolean _out; } diff --git a/src/java/com/threerings/crowd/chat/client/ChatFilter.java b/src/java/com/threerings/crowd/chat/client/ChatFilter.java index 308a7ae56..f10b5fb8a 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatFilter.java +++ b/src/java/com/threerings/crowd/chat/client/ChatFilter.java @@ -1,8 +1,10 @@ // -// $Id: ChatFilter.java,v 1.1 2003/09/15 21:11:40 ray Exp $ +// $Id: ChatFilter.java,v 1.2 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.client; +import com.threerings.util.Name; + /** * Filters messages chat messages to or from the server. */ @@ -18,5 +20,5 @@ public interface ChatFilter * * @return the filtered message, or null to block it completely. */ - public String filter (String msg, String otherUser, boolean outgoing); + public String filter (String msg, Name otherUser, boolean outgoing); } diff --git a/src/java/com/threerings/crowd/chat/client/ChatService.java b/src/java/com/threerings/crowd/chat/client/ChatService.java index 2938240b3..99aaa6a8a 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatService.java +++ b/src/java/com/threerings/crowd/chat/client/ChatService.java @@ -1,8 +1,10 @@ // -// $Id: ChatService.java,v 1.12 2003/09/18 17:53:48 mdb Exp $ +// $Id: ChatService.java,v 1.13 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.client; +import com.threerings.util.Name; + import com.threerings.presents.client.Client; import com.threerings.presents.client.InvocationService; @@ -41,7 +43,7 @@ public interface ChatService extends InvocationService * @param message the contents of the message. * @param listener the reference that will receive the tell response. */ - public void tell (Client client, String target, String message, + public void tell (Client client, Name target, String message, TellListener listener); /** diff --git a/src/java/com/threerings/crowd/chat/client/MuteDirector.java b/src/java/com/threerings/crowd/chat/client/MuteDirector.java index 90342b42c..f6831f749 100644 --- a/src/java/com/threerings/crowd/chat/client/MuteDirector.java +++ b/src/java/com/threerings/crowd/chat/client/MuteDirector.java @@ -1,5 +1,5 @@ // -// $Id: MuteDirector.java,v 1.10 2003/09/15 21:11:40 ray Exp $ +// $Id: MuteDirector.java,v 1.11 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.client; @@ -8,6 +8,7 @@ import java.util.HashSet; import com.samskivert.util.ObserverList; import com.threerings.util.MessageBundle; +import com.threerings.util.Name; import com.threerings.crowd.util.CrowdContext; @@ -31,7 +32,7 @@ public class MuteDirector extends BasicDirector /** * The specified player was added or removed from the mutelist. */ - public void muteChanged (String playername, boolean nowMuted); + public void muteChanged (Name playername, boolean nowMuted); } /** @@ -45,7 +46,7 @@ public class MuteDirector extends BasicDirector /** * Set up the mute director with the specified list of initial mutees. */ - public MuteDirector (CrowdContext ctx, String[] list) + public MuteDirector (CrowdContext ctx, Name[] list) { this(ctx); @@ -84,7 +85,7 @@ public class MuteDirector extends BasicDirector /** * Check to see if the specified user is muted. */ - public boolean isMuted (String username) + public boolean isMuted (Name username) { return _mutelist.contains(username); } @@ -92,7 +93,7 @@ public class MuteDirector extends BasicDirector /** * Mute or unmute the specified user. */ - public void setMuted (String username, boolean mute) + public void setMuted (Name username, boolean mute) { if (mute ? _mutelist.add(username) : _mutelist.remove(username)) { _chatdir.displayFeedback(null, MessageBundle.tcompose( @@ -107,13 +108,13 @@ public class MuteDirector extends BasicDirector * This list may be out of date immediately upon returning from this * method. */ - public String[] getMuted () + public Name[] getMuted () { - return (String[]) _mutelist.toArray(new String[_mutelist.size()]); + return (Name[]) _mutelist.toArray(new Name[_mutelist.size()]); } // documentation inherited from interface ChatFilter - public String filter (String msg, String otherUser, boolean outgoing) + public String filter (String msg, Name otherUser, boolean outgoing) { // we are only concerned with filtering things going to or coming // from muted users @@ -132,7 +133,7 @@ public class MuteDirector extends BasicDirector /** * Notify our observers of a change in the mutelist. */ - protected void notifyObservers (final String username, final boolean muted) + protected void notifyObservers (final Name username, final boolean muted) { _observers.apply(new ObserverList.ObserverOp() { public boolean apply (Object observer) { diff --git a/src/java/com/threerings/crowd/chat/data/ChatMarshaller.java b/src/java/com/threerings/crowd/chat/data/ChatMarshaller.java index 8d7292a62..3dc717d21 100644 --- a/src/java/com/threerings/crowd/chat/data/ChatMarshaller.java +++ b/src/java/com/threerings/crowd/chat/data/ChatMarshaller.java @@ -1,12 +1,15 @@ // -// $Id: ChatMarshaller.java,v 1.7 2004/02/25 14:41:47 mdb Exp $ +// $Id: ChatMarshaller.java,v 1.8 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.data; import com.threerings.crowd.chat.client.ChatService; +import com.threerings.crowd.chat.client.ChatService.TellListener; import com.threerings.presents.client.Client; +import com.threerings.presents.client.InvocationService.InvocationListener; import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.dobj.InvocationResponseEvent; +import com.threerings.util.Name; /** * Provides the implementation of the {@link ChatService} interface @@ -53,7 +56,7 @@ public class ChatMarshaller extends InvocationMarshaller public static final int TELL = 1; // documentation inherited from interface - public void tell (Client arg1, String arg2, String arg3, TellListener arg4) + public void tell (Client arg1, Name arg2, String arg3, TellListener arg4) { TellMarshaller listener4 = new TellMarshaller(); listener4.listener = arg4; diff --git a/src/java/com/threerings/crowd/chat/data/SpeakObject.java b/src/java/com/threerings/crowd/chat/data/SpeakObject.java index 65d2fb486..f040b83e9 100644 --- a/src/java/com/threerings/crowd/chat/data/SpeakObject.java +++ b/src/java/com/threerings/crowd/chat/data/SpeakObject.java @@ -1,8 +1,10 @@ // -// $Id: SpeakObject.java,v 1.2 2003/06/14 00:59:24 mdb Exp $ +// $Id: SpeakObject.java,v 1.3 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.data; +import com.threerings.util.Name; + /** * Provides a mechanism by which the speak service can identify chat * listeners so as to maintain a recent history of all chat traffic on the @@ -17,7 +19,7 @@ public interface SpeakObject public void apply (int bodyOid); /** Call this method if you can provide usernames directly. */ - public void apply (String username); + public void apply (Name username); } /** diff --git a/src/java/com/threerings/crowd/chat/data/UserMessage.java b/src/java/com/threerings/crowd/chat/data/UserMessage.java index a3dc57d34..adfe0bf21 100644 --- a/src/java/com/threerings/crowd/chat/data/UserMessage.java +++ b/src/java/com/threerings/crowd/chat/data/UserMessage.java @@ -1,15 +1,17 @@ // -// $Id: UserMessage.java,v 1.2 2003/06/03 21:41:33 ray Exp $ +// $Id: UserMessage.java,v 1.3 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.data; +import com.threerings.util.Name; + /** * A ChatMessage representing a message that came from another user. */ public class UserMessage extends ChatMessage { /** The user that the message came from. */ - public String speaker; + public Name speaker; /** The mode of the message. @see ChatCodes.DEFAULT_MODE */ public byte mode; @@ -24,8 +26,7 @@ public class UserMessage extends ChatMessage /** * Construct a user message. */ - public UserMessage (String message, String bundle, - String speaker, byte mode) + public UserMessage (String message, String bundle, Name speaker, byte mode) { super(message, bundle); this.speaker = speaker; diff --git a/src/java/com/threerings/crowd/chat/server/ChatDispatcher.java b/src/java/com/threerings/crowd/chat/server/ChatDispatcher.java index 3c89c847c..5d46b5daa 100644 --- a/src/java/com/threerings/crowd/chat/server/ChatDispatcher.java +++ b/src/java/com/threerings/crowd/chat/server/ChatDispatcher.java @@ -1,15 +1,18 @@ // -// $Id: ChatDispatcher.java,v 1.7 2004/02/25 14:41:47 mdb Exp $ +// $Id: ChatDispatcher.java,v 1.8 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.server; +import com.threerings.crowd.chat.client.ChatService; import com.threerings.crowd.chat.client.ChatService.TellListener; import com.threerings.crowd.chat.data.ChatMarshaller; +import com.threerings.presents.client.Client; import com.threerings.presents.client.InvocationService.InvocationListener; import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.server.InvocationDispatcher; import com.threerings.presents.server.InvocationException; +import com.threerings.util.Name; /** * Dispatches requests to the {@link ChatProvider}. @@ -40,7 +43,7 @@ public class ChatDispatcher extends InvocationDispatcher case ChatMarshaller.TELL: ((ChatProvider)provider).tell( source, - (String)args[0], (String)args[1], (TellListener)args[2] + (Name)args[0], (String)args[1], (TellListener)args[2] ); return; diff --git a/src/java/com/threerings/crowd/chat/server/ChatProvider.java b/src/java/com/threerings/crowd/chat/server/ChatProvider.java index baffcc1b3..b79a7d303 100644 --- a/src/java/com/threerings/crowd/chat/server/ChatProvider.java +++ b/src/java/com/threerings/crowd/chat/server/ChatProvider.java @@ -1,5 +1,5 @@ // -// $Id: ChatProvider.java,v 1.26 2004/02/25 14:41:47 mdb Exp $ +// $Id: ChatProvider.java,v 1.27 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.server; @@ -7,6 +7,7 @@ import java.util.Iterator; import com.samskivert.util.StringUtil; import com.threerings.util.MessageBundle; +import com.threerings.util.Name; import com.threerings.util.TimeUtil; import com.threerings.presents.client.InvocationService.InvocationListener; @@ -84,7 +85,7 @@ public class ChatProvider * Processes a request from a client to deliver a tell message to * another client. */ - public void tell (ClientObject caller, String target, String message, + public void tell (ClientObject caller, Name target, String message, TellListener listener) throws InvocationException { @@ -177,7 +178,7 @@ public class ChatProvider * @param message the text of the chat message. */ public static void sendTellMessage ( - BodyObject target, String speaker, String bundle, String message) + BodyObject target, Name speaker, String bundle, String message) { UserMessage msg = new UserMessage(message, bundle, speaker, DEFAULT_MODE); diff --git a/src/java/com/threerings/crowd/chat/server/SpeakProvider.java b/src/java/com/threerings/crowd/chat/server/SpeakProvider.java index 2c7d5bd1b..cc64d8f71 100644 --- a/src/java/com/threerings/crowd/chat/server/SpeakProvider.java +++ b/src/java/com/threerings/crowd/chat/server/SpeakProvider.java @@ -1,5 +1,5 @@ // -// $Id: SpeakProvider.java,v 1.19 2004/02/25 14:41:47 mdb Exp $ +// $Id: SpeakProvider.java,v 1.20 2004/03/06 11:29:18 mdb Exp $ package com.threerings.crowd.chat.server; @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.HashMap; import com.samskivert.util.ObserverList; +import com.threerings.util.Name; import com.threerings.presents.data.ClientObject; import com.threerings.presents.dobj.DObject; @@ -55,7 +56,7 @@ public class SpeakProvider /** * Called for each player that hears a particular chat message. */ - public void messageDelivered (String hearer, UserMessage message); + public void messageDelivered (Name hearer, UserMessage message); } /** @@ -144,7 +145,7 @@ public class SpeakProvider * "faking" a chat message. * @param message the text of the speak message. */ - public static void sendSpeak (DObject speakObj, String speaker, + public static void sendSpeak (DObject speakObj, Name speaker, String bundle, String message) { sendSpeak(speakObj, speaker, bundle, message, ChatCodes.DEFAULT_MODE); @@ -167,7 +168,7 @@ public class SpeakProvider * @param mode the mode of the message, see {@link * ChatCodes#DEFAULT_MODE}. */ - public static void sendSpeak (DObject speakObj, String speaker, + public static void sendSpeak (DObject speakObj, Name speaker, String bundle, String message, byte mode) { sendMessage(speakObj, new UserMessage(message, bundle, speaker, mode)); @@ -277,7 +278,7 @@ public class SpeakProvider * Returns a list of {@link ChatMessage} objects to which this user * has been privy in the recent past. */ - public static ArrayList getChatHistory (String username) + public static ArrayList getChatHistory (Name username) { HistoryList history = getHistoryList(username); pruneHistory(System.currentTimeMillis(), history); @@ -287,7 +288,7 @@ public class SpeakProvider /** * Called to clear the chat history for the specified user. */ - public static void clearHistory (String username) + public static void clearHistory (Name username) { // Log.info("Clearing history for " + username + "."); _histories.remove(username); @@ -298,7 +299,7 @@ public class SpeakProvider * message. If {@link ChatMessage#timestamp} is not already filled in, * it will be. */ - protected static void noteMessage (String username, UserMessage msg) + protected static void noteMessage (Name username, UserMessage msg) { // fill in the message's time stamp if necessary if (msg.timestamp == 0L) { @@ -325,7 +326,7 @@ public class SpeakProvider /** * Returns this user's chat history, creating one if necessary. */ - protected static HistoryList getHistoryList (String username) + protected static HistoryList getHistoryList (Name username) { HistoryList history = (HistoryList)_histories.get(username); if (history == null) { @@ -361,7 +362,7 @@ public class SpeakProvider } } - public void apply (String username) { + public void apply (Name username) { noteMessage(username, message); } } @@ -378,7 +379,7 @@ public class SpeakProvider /** Used to notify our {@link MessageObserver}s. */ protected static class MessageObserverOp implements ObserverList.ObserverOp { - public void init (String hearer, UserMessage message) { + public void init (Name hearer, UserMessage message) { _hearer = hearer; _message = message; } @@ -388,7 +389,7 @@ public class SpeakProvider return true; } - protected String _hearer; + protected Name _hearer; protected UserMessage _message; } diff --git a/src/java/com/threerings/crowd/client/OccupantDirector.java b/src/java/com/threerings/crowd/client/OccupantDirector.java index 87f037a91..31f99f96e 100644 --- a/src/java/com/threerings/crowd/client/OccupantDirector.java +++ b/src/java/com/threerings/crowd/client/OccupantDirector.java @@ -1,5 +1,5 @@ // -// $Id: OccupantDirector.java,v 1.6 2002/10/27 23:30:56 shaper Exp $ +// $Id: OccupantDirector.java,v 1.7 2004/03/06 11:29:19 mdb Exp $ package com.threerings.crowd.client; @@ -7,6 +7,7 @@ import java.util.Iterator; import com.samskivert.util.HashIntMap; import com.samskivert.util.ObserverList; +import com.threerings.util.Name; import com.threerings.presents.client.BasicDirector; import com.threerings.presents.client.Client; @@ -88,7 +89,7 @@ public class OccupantDirector extends BasicDirector * the currently occupied place. Returns null if no occupant info * exists with the specified username. */ - public OccupantInfo getOccupantInfo (String username) + public OccupantInfo getOccupantInfo (Name username) { // make sure we're somewhere if (_place == null) { diff --git a/src/java/com/threerings/crowd/data/BodyObject.dobj b/src/java/com/threerings/crowd/data/BodyObject.dobj index a586364ea..f4da180fa 100644 --- a/src/java/com/threerings/crowd/data/BodyObject.dobj +++ b/src/java/com/threerings/crowd/data/BodyObject.dobj @@ -1,8 +1,10 @@ // -// $Id: BodyObject.dobj,v 1.13 2003/09/18 17:53:48 mdb Exp $ +// $Id: BodyObject.dobj,v 1.14 2004/03/06 11:29:19 mdb Exp $ package com.threerings.crowd.data; +import com.threerings.util.Name; + import com.threerings.presents.data.ClientObject; import com.threerings.crowd.chat.data.SpeakObject; @@ -16,7 +18,7 @@ public class BodyObject extends ClientObject /** * The username associated with this body object. */ - public String username; + public Name username; /** * The oid of the place currently occupied by this body or -1 if they @@ -50,7 +52,7 @@ public class BodyObject extends ClientObject // documentation inherited public String who () { - StringBuffer buf = new StringBuffer(username); + StringBuffer buf = new StringBuffer(username.toString()); buf.append(" (").append(getOid()); if (status != OccupantInfo.ACTIVE) { buf.append(" ").append(OccupantInfo.X_STATUS[status]); diff --git a/src/java/com/threerings/crowd/data/BodyObject.java b/src/java/com/threerings/crowd/data/BodyObject.java index 6debc80ac..b2f31a139 100644 --- a/src/java/com/threerings/crowd/data/BodyObject.java +++ b/src/java/com/threerings/crowd/data/BodyObject.java @@ -1,8 +1,10 @@ // -// $Id: BodyObject.java,v 1.8 2003/09/18 17:53:48 mdb Exp $ +// $Id: BodyObject.java,v 1.9 2004/03/06 11:29:19 mdb Exp $ package com.threerings.crowd.data; +import com.threerings.util.Name; + import com.threerings.presents.data.ClientObject; import com.threerings.crowd.chat.data.SpeakObject; @@ -28,7 +30,7 @@ public class BodyObject extends ClientObject /** * The username associated with this body object. */ - public String username; + public Name username; /** * The oid of the place currently occupied by this body or -1 if they @@ -62,7 +64,7 @@ public class BodyObject extends ClientObject // documentation inherited public String who () { - StringBuffer buf = new StringBuffer(username); + StringBuffer buf = new StringBuffer(username.toString()); buf.append(" (").append(getOid()); if (status != OccupantInfo.ACTIVE) { buf.append(" ").append(OccupantInfo.X_STATUS[status]); @@ -78,7 +80,7 @@ public class BodyObject extends ClientObject * clients) will apply the value change when they received the * attribute changed notification. */ - public void setUsername (String username) + public void setUsername (Name username) { requestAttributeChange(USERNAME, username); this.username = username; diff --git a/src/java/com/threerings/crowd/data/OccupantInfo.java b/src/java/com/threerings/crowd/data/OccupantInfo.java index c1fa155a4..debf1fea5 100644 --- a/src/java/com/threerings/crowd/data/OccupantInfo.java +++ b/src/java/com/threerings/crowd/data/OccupantInfo.java @@ -1,9 +1,11 @@ // -// $Id: OccupantInfo.java,v 1.11 2002/10/30 00:42:37 mdb Exp $ +// $Id: OccupantInfo.java,v 1.12 2004/03/06 11:29:19 mdb Exp $ package com.threerings.crowd.data; import com.threerings.io.SimpleStreamableObject; +import com.threerings.util.Name; + import com.threerings.presents.dobj.DSet; /** @@ -43,7 +45,7 @@ public class OccupantInfo extends SimpleStreamableObject public Integer bodyOid; /** The username of this occupant. */ - public String username; + public Name username; /** The status of this occupant. */ public byte status = ACTIVE; diff --git a/src/java/com/threerings/crowd/data/PlaceObject.dobj b/src/java/com/threerings/crowd/data/PlaceObject.dobj index 8f7b0d8a6..d20a1aea9 100644 --- a/src/java/com/threerings/crowd/data/PlaceObject.dobj +++ b/src/java/com/threerings/crowd/data/PlaceObject.dobj @@ -1,10 +1,12 @@ // -// $Id: PlaceObject.dobj,v 1.16 2003/07/11 00:47:33 mdb Exp $ +// $Id: PlaceObject.dobj,v 1.17 2004/03/06 11:29:19 mdb Exp $ package com.threerings.crowd.data; import java.util.Iterator; +import com.threerings.util.Name; + import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DSet; import com.threerings.presents.dobj.OidList; @@ -59,7 +61,7 @@ public class PlaceObject extends DObject * @return the occupant info record for the named user or null if no * user in the room has that username. */ - public OccupantInfo getOccupantInfo (String username) + public OccupantInfo getOccupantInfo (Name username) { try { Iterator iter = occupantInfo.entries(); diff --git a/src/java/com/threerings/crowd/data/PlaceObject.java b/src/java/com/threerings/crowd/data/PlaceObject.java index 59451ab4f..103e922b0 100644 --- a/src/java/com/threerings/crowd/data/PlaceObject.java +++ b/src/java/com/threerings/crowd/data/PlaceObject.java @@ -1,10 +1,12 @@ // -// $Id: PlaceObject.java,v 1.15 2003/07/11 00:47:33 mdb Exp $ +// $Id: PlaceObject.java,v 1.16 2004/03/06 11:29:19 mdb Exp $ package com.threerings.crowd.data; import java.util.Iterator; +import com.threerings.util.Name; + import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DSet; import com.threerings.presents.dobj.OidList; @@ -68,7 +70,7 @@ public class PlaceObject extends DObject * @return the occupant info record for the named user or null if no * user in the room has that username. */ - public OccupantInfo getOccupantInfo (String username) + public OccupantInfo getOccupantInfo (Name username) { try { Iterator iter = occupantInfo.entries(); diff --git a/src/java/com/threerings/crowd/server/CrowdServer.java b/src/java/com/threerings/crowd/server/CrowdServer.java index bafa8c20b..f7c44e466 100644 --- a/src/java/com/threerings/crowd/server/CrowdServer.java +++ b/src/java/com/threerings/crowd/server/CrowdServer.java @@ -1,10 +1,12 @@ // -// $Id: CrowdServer.java,v 1.18 2003/06/03 21:41:33 ray Exp $ +// $Id: CrowdServer.java,v 1.19 2004/03/06 11:29:19 mdb Exp $ package com.threerings.crowd.server; import java.util.Iterator; +import com.threerings.util.Name; + import com.threerings.presents.server.PresentsServer; import com.threerings.crowd.Log; @@ -86,7 +88,7 @@ public class CrowdServer extends PresentsServer * active users on the server. This should only be called from the * dobjmgr thread. */ - public static BodyObject lookupBody (String username) + public static BodyObject lookupBody (Name username) { return (BodyObject)clmgr.getClientObject(username); } diff --git a/src/java/com/threerings/micasa/client/ChatPanel.java b/src/java/com/threerings/micasa/client/ChatPanel.java index b1141b530..7c49e1e06 100644 --- a/src/java/com/threerings/micasa/client/ChatPanel.java +++ b/src/java/com/threerings/micasa/client/ChatPanel.java @@ -1,5 +1,5 @@ // -// $Id: ChatPanel.java,v 1.26 2004/02/25 14:43:37 mdb Exp $ +// $Id: ChatPanel.java,v 1.27 2004/03/06 11:29:19 mdb Exp $ package com.threerings.micasa.client; @@ -31,6 +31,8 @@ import com.samskivert.swing.HGroupLayout; import com.samskivert.swing.VGroupLayout; import com.samskivert.swing.event.AncestorAdapter; +import com.threerings.util.Name; + import com.threerings.crowd.chat.client.ChatDirector; import com.threerings.crowd.chat.client.ChatDisplay; import com.threerings.crowd.chat.data.ChatCodes; @@ -202,7 +204,7 @@ public class ChatPanel String message = text.substring(uidx + username.length()).trim(); // request to send this text as a tell message - _chatdtr.requestTell(username, message, null); + _chatdtr.requestTell(new Name(username), message, null); } else if (text.startsWith("/clear")) { // clear the chat box diff --git a/src/java/com/threerings/micasa/client/LogonPanel.java b/src/java/com/threerings/micasa/client/LogonPanel.java index 2fbe820b1..009120e9f 100644 --- a/src/java/com/threerings/micasa/client/LogonPanel.java +++ b/src/java/com/threerings/micasa/client/LogonPanel.java @@ -1,5 +1,5 @@ // -// $Id: LogonPanel.java,v 1.9 2004/02/25 14:43:37 mdb Exp $ +// $Id: LogonPanel.java,v 1.10 2004/03/06 11:29:19 mdb Exp $ package com.threerings.micasa.client; @@ -21,6 +21,7 @@ import com.samskivert.swing.HGroupLayout; import com.samskivert.swing.VGroupLayout; import com.threerings.util.MessageBundle; +import com.threerings.util.Name; import com.threerings.presents.client.Client; import com.threerings.presents.client.ClientObserver; @@ -182,7 +183,7 @@ public class LogonPanel extends JPanel // disable further logon attempts until we hear back setLogonEnabled(false); - String username = _username.getText().trim(); + Name username = new Name(_username.getText().trim()); String password = new String(_password.getPassword()).trim(); String server = _ctx.getClient().getHostname(); diff --git a/src/java/com/threerings/micasa/client/MiCasaApp.java b/src/java/com/threerings/micasa/client/MiCasaApp.java index f45d7eb9e..0a04fec2d 100644 --- a/src/java/com/threerings/micasa/client/MiCasaApp.java +++ b/src/java/com/threerings/micasa/client/MiCasaApp.java @@ -1,13 +1,14 @@ // -// $Id: MiCasaApp.java,v 1.12 2004/02/22 18:55:26 ray Exp $ +// $Id: MiCasaApp.java,v 1.13 2004/03/06 11:29:19 mdb Exp $ package com.threerings.micasa.client; import java.io.IOException; + import com.samskivert.swing.util.SwingUtil; +import com.threerings.util.Name; import com.threerings.presents.client.Client; -import com.threerings.presents.net.Credentials; import com.threerings.presents.net.UsernamePasswordCreds; import com.threerings.micasa.Log; @@ -75,8 +76,8 @@ public class MiCasaApp String password = getProperty("password"); if (username != null && password != null) { // create and set our credentials - Credentials creds = new UsernamePasswordCreds(username, password); - client.setCredentials(creds); + client.setCredentials( + new UsernamePasswordCreds(new Name(username), password)); client.logon(); } } diff --git a/src/java/com/threerings/micasa/client/MiCasaApplet.java b/src/java/com/threerings/micasa/client/MiCasaApplet.java index eeacf8e61..bbe71c0cc 100644 --- a/src/java/com/threerings/micasa/client/MiCasaApplet.java +++ b/src/java/com/threerings/micasa/client/MiCasaApplet.java @@ -1,11 +1,13 @@ // -// $Id: MiCasaApplet.java,v 1.7 2002/08/14 19:07:49 mdb Exp $ +// $Id: MiCasaApplet.java,v 1.8 2004/03/06 11:29:19 mdb Exp $ package com.threerings.micasa.client; import java.applet.Applet; import java.io.IOException; + import com.samskivert.swing.util.SwingUtil; +import com.threerings.util.Name; import com.threerings.presents.client.Client; import com.threerings.presents.client.ClientAdapter; @@ -32,7 +34,7 @@ public class MiCasaApplet extends Applet _client = new MiCasaClient(); _client.init(_frame); - String username = requireParameter("username"); + Name username = new Name(requireParameter("username")); String authkey = requireParameter("authkey"); String server = getCodeBase().getHost(); diff --git a/src/java/com/threerings/micasa/lobby/LobbyController.java b/src/java/com/threerings/micasa/lobby/LobbyController.java index a391b94da..fd16c7f5d 100644 --- a/src/java/com/threerings/micasa/lobby/LobbyController.java +++ b/src/java/com/threerings/micasa/lobby/LobbyController.java @@ -1,8 +1,10 @@ // -// $Id: LobbyController.java,v 1.9 2002/08/14 19:07:49 mdb Exp $ +// $Id: LobbyController.java,v 1.10 2004/03/06 11:29:19 mdb Exp $ package com.threerings.micasa.lobby; +import com.threerings.util.Name; + import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.client.PlaceController; @@ -48,7 +50,8 @@ public class LobbyController extends PlaceController // create a game config object try { GameConfig config = _config.getGameConfig(); - _ctx.getParlorDirector().invite(invitee, config, this); + _ctx.getParlorDirector().invite( + new Name(invitee), config, this); } catch (Exception e) { Log.warning("Error instantiating game config."); Log.logStackTrace(e); diff --git a/src/java/com/threerings/micasa/lobby/table/TableItem.java b/src/java/com/threerings/micasa/lobby/table/TableItem.java index be90fec5c..3ea028782 100644 --- a/src/java/com/threerings/micasa/lobby/table/TableItem.java +++ b/src/java/com/threerings/micasa/lobby/table/TableItem.java @@ -1,5 +1,5 @@ // -// $Id: TableItem.java,v 1.3 2001/10/24 01:26:54 mdb Exp $ +// $Id: TableItem.java,v 1.4 2004/03/06 11:29:19 mdb Exp $ package com.threerings.micasa.lobby.table; @@ -16,7 +16,7 @@ import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; -import com.samskivert.util.StringUtil; +import com.threerings.util.Name; import com.threerings.crowd.data.BodyObject; @@ -137,7 +137,7 @@ public class TableItem // now enable and label the buttons accordingly int slength = _seats.length; for (int i = 0; i < slength; i++) { - if (StringUtil.blank(table.occupants[i])) { + if (table.occupants[i] == null) { _seats[i].setText(JOIN_LABEL); _seats[i].setEnabled(!isSeated); _seats[i].setActionCommand("join"); @@ -149,7 +149,7 @@ public class TableItem _seats[i].setActionCommand("leave"); } else { - _seats[i].setText(table.occupants[i]); + _seats[i].setText(table.occupants[i].toString()); _seats[i].setEnabled(false); } } @@ -220,7 +220,7 @@ public class TableItem protected MiCasaContext _ctx; /** Our username. */ - protected String _self; + protected Name _self; /** A reference to our table director. */ protected TableDirector _tdtr; diff --git a/src/java/com/threerings/micasa/simulator/client/SimulatorApp.java b/src/java/com/threerings/micasa/simulator/client/SimulatorApp.java index 4cc82ca5e..8b2abdc0f 100644 --- a/src/java/com/threerings/micasa/simulator/client/SimulatorApp.java +++ b/src/java/com/threerings/micasa/simulator/client/SimulatorApp.java @@ -1,5 +1,5 @@ // -// $Id: SimulatorApp.java,v 1.15 2004/02/22 18:55:26 ray Exp $ +// $Id: SimulatorApp.java,v 1.16 2004/03/06 11:29:19 mdb Exp $ package com.threerings.micasa.simulator.client; @@ -11,9 +11,10 @@ import com.samskivert.util.Interval; import com.samskivert.util.IntervalManager; import com.samskivert.util.ResultListener; +import com.threerings.util.Name; + import com.threerings.presents.client.Client; import com.threerings.presents.client.ClientAdapter; -import com.threerings.presents.net.Credentials; import com.threerings.presents.net.UsernamePasswordCreds; import com.threerings.micasa.Log; @@ -139,8 +140,8 @@ public class SimulatorApp } // create and set our credentials - Credentials creds = new UsernamePasswordCreds(username, password); - client.setCredentials(creds); + client.setCredentials( + new UsernamePasswordCreds(new Name(username), password)); // this is a bit of a hack, but we need to give the server long // enough to fully initialize and start listening on its socket diff --git a/src/java/com/threerings/micasa/simulator/server/SimulatorManager.java b/src/java/com/threerings/micasa/simulator/server/SimulatorManager.java index c687f65c1..7f04ba9ec 100644 --- a/src/java/com/threerings/micasa/simulator/server/SimulatorManager.java +++ b/src/java/com/threerings/micasa/simulator/server/SimulatorManager.java @@ -1,10 +1,12 @@ // -// $Id: SimulatorManager.java,v 1.15 2004/02/25 14:43:37 mdb Exp $ +// $Id: SimulatorManager.java,v 1.16 2004/03/06 11:29:19 mdb Exp $ package com.threerings.micasa.simulator.server; import java.util.ArrayList; +import com.threerings.util.Name; + import com.threerings.presents.data.ClientObject; import com.threerings.presents.dobj.RootDObjectManager; import com.threerings.presents.server.ClientManager; @@ -82,10 +84,10 @@ public class SimulatorManager // once the game object creation has completed) // configure the game config with the player names - config.players = new String[_playerCount]; + config.players = new Name[_playerCount]; config.players[0] = _source.username; for (int ii = 1; ii < _playerCount; ii++) { - config.players[ii] = "simulant" + ii; + config.players[ii] = new Name("simulant" + ii); } // we needn't hang around and wait for game object @@ -121,7 +123,7 @@ public class SimulatorManager // resolve the simulant body objects ClientResolutionListener listener = new ClientResolutionListener() { - public void clientResolved (String username, ClientObject clobj) + public void clientResolved (Name username, ClientObject clobj) { // hold onto the body object for later game creation _sims.add(clobj); @@ -132,7 +134,7 @@ public class SimulatorManager } } - public void resolutionFailed (String username, Exception cause) + public void resolutionFailed (Name username, Exception cause) { Log.warning("Unable to create simulant body object " + "[error=" + cause + "]."); @@ -141,7 +143,7 @@ public class SimulatorManager // resolve client objects for all of our simulants for (int ii = 1; ii < _playerCount; ii++) { - String username = "simulant" + ii; + Name username = new Name("simulant" + ii); _clmgr.resolveClientObject(username, listener); } } diff --git a/src/java/com/threerings/parlor/client/Invitation.java b/src/java/com/threerings/parlor/client/Invitation.java index 89542768f..6f5b4bf99 100644 --- a/src/java/com/threerings/parlor/client/Invitation.java +++ b/src/java/com/threerings/parlor/client/Invitation.java @@ -1,8 +1,10 @@ // -// $Id: Invitation.java,v 1.2 2004/02/25 14:44:54 mdb Exp $ +// $Id: Invitation.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.client; +import com.threerings.util.Name; + import com.threerings.parlor.Log; import com.threerings.parlor.data.ParlorCodes; import com.threerings.parlor.game.GameConfig; @@ -21,14 +23,14 @@ public class Invitation public int inviteId = -1; /** The name of the other user involved in this invitation. */ - public String opponent; + public Name opponent; /** The configuration of the game to be created. */ public GameConfig config; /** Constructs a new invitation record. */ public Invitation (ParlorContext ctx, ParlorService pservice, - String opponent, GameConfig config, + Name opponent, GameConfig config, InvitationResponseObserver observer) { _ctx = ctx; diff --git a/src/java/com/threerings/parlor/client/ParlorDecoder.java b/src/java/com/threerings/parlor/client/ParlorDecoder.java index d562936d2..782fb131a 100644 --- a/src/java/com/threerings/parlor/client/ParlorDecoder.java +++ b/src/java/com/threerings/parlor/client/ParlorDecoder.java @@ -1,18 +1,15 @@ // -// $Id: ParlorDecoder.java,v 1.2 2002/08/20 19:38:14 mdb Exp $ +// $Id: ParlorDecoder.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.client; import com.threerings.parlor.client.ParlorReceiver; import com.threerings.parlor.game.GameConfig; import com.threerings.presents.client.InvocationDecoder; +import com.threerings.util.Name; /** * Dispatches calls to a {@link ParlorReceiver} instance. - * - *

Generated from - * $Id: ParlorDecoder.java,v 1.2 2002/08/20 19:38:14 mdb Exp $ - * */ public class ParlorDecoder extends InvocationDecoder { @@ -62,7 +59,7 @@ public class ParlorDecoder extends InvocationDecoder case RECEIVED_INVITE: ((ParlorReceiver)receiver).receivedInvite( - ((Integer)args[0]).intValue(), (String)args[1], (GameConfig)args[2] + ((Integer)args[0]).intValue(), (Name)args[1], (GameConfig)args[2] ); return; @@ -82,6 +79,4 @@ public class ParlorDecoder extends InvocationDecoder super.dispatchNotification(methodId, args); } } - - // Generated on 12:37:00 08/20/02. } diff --git a/src/java/com/threerings/parlor/client/ParlorDirector.java b/src/java/com/threerings/parlor/client/ParlorDirector.java index 80bf59c3e..96db7f7fe 100644 --- a/src/java/com/threerings/parlor/client/ParlorDirector.java +++ b/src/java/com/threerings/parlor/client/ParlorDirector.java @@ -1,10 +1,12 @@ // -// $Id: ParlorDirector.java,v 1.19 2004/02/25 14:44:54 mdb Exp $ +// $Id: ParlorDirector.java,v 1.20 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.client; import java.util.ArrayList; + import com.samskivert.util.HashIntMap; +import com.threerings.util.Name; import com.threerings.presents.client.BasicDirector; import com.threerings.presents.client.Client; @@ -87,7 +89,7 @@ public class ParlorDirector extends BasicDirector * @return an invitation object that can be used to manage the * outstanding invitation. */ - public Invitation invite (String invitee, GameConfig config, + public Invitation invite (Name invitee, GameConfig config, InvitationResponseObserver observer) { // create the invitation record @@ -134,8 +136,7 @@ public class ParlorDirector extends BasicDirector } // documentation inherited from interface - public void receivedInvite ( - int remoteId, String inviter, GameConfig config) + public void receivedInvite (int remoteId, Name inviter, GameConfig config) { // create an invitation record for this invitation Invitation invite = new Invitation( diff --git a/src/java/com/threerings/parlor/client/ParlorReceiver.java b/src/java/com/threerings/parlor/client/ParlorReceiver.java index 1e862ff1c..b7c88d865 100644 --- a/src/java/com/threerings/parlor/client/ParlorReceiver.java +++ b/src/java/com/threerings/parlor/client/ParlorReceiver.java @@ -1,8 +1,10 @@ // -// $Id: ParlorReceiver.java,v 1.2 2004/02/25 14:44:54 mdb Exp $ +// $Id: ParlorReceiver.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.client; +import com.threerings.util.Name; + import com.threerings.presents.client.InvocationReceiver; import com.threerings.parlor.game.GameConfig; @@ -34,8 +36,7 @@ public interface ParlorReceiver extends InvocationReceiver * @param config the configuration information for the game to which * we've been invited. */ - public void receivedInvite ( - int remoteId, String inviter, GameConfig config); + public void receivedInvite (int remoteId, Name inviter, GameConfig config); /** * Called by the invocation services when another user has responded @@ -52,8 +53,7 @@ public interface ParlorReceiver extends InvocationReceiver * provided). In the case of a countered invitation, a new game config * object with the modified game configuration. */ - public void receivedInviteResponse ( - int remoteId, int code, Object arg); + public void receivedInviteResponse (int remoteId, int code, Object arg); /** * Called by the invocation services when an outstanding invitation diff --git a/src/java/com/threerings/parlor/client/ParlorService.java b/src/java/com/threerings/parlor/client/ParlorService.java index d15b74c3a..7aa4830af 100644 --- a/src/java/com/threerings/parlor/client/ParlorService.java +++ b/src/java/com/threerings/parlor/client/ParlorService.java @@ -1,8 +1,10 @@ // -// $Id: ParlorService.java,v 1.14 2002/10/27 18:49:51 mdb Exp $ +// $Id: ParlorService.java,v 1.15 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.client; +import com.threerings.util.Name; + import com.threerings.presents.client.Client; import com.threerings.presents.client.InvocationService; @@ -41,7 +43,7 @@ public interface ParlorService extends InvocationService * configuration of the game to be created. * @param listener will receive and process the response. */ - public void invite (Client client, String invitee, GameConfig config, + public void invite (Client client, Name invitee, GameConfig config, InviteListener listener); /** diff --git a/src/java/com/threerings/parlor/data/ParlorMarshaller.java b/src/java/com/threerings/parlor/data/ParlorMarshaller.java index 8e774ce47..190366016 100644 --- a/src/java/com/threerings/parlor/data/ParlorMarshaller.java +++ b/src/java/com/threerings/parlor/data/ParlorMarshaller.java @@ -1,5 +1,5 @@ // -// $Id: ParlorMarshaller.java,v 1.2 2002/08/20 19:38:14 mdb Exp $ +// $Id: ParlorMarshaller.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.data; @@ -11,6 +11,7 @@ import com.threerings.presents.client.Client; import com.threerings.presents.client.InvocationService.InvocationListener; import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.dobj.InvocationResponseEvent; +import com.threerings.util.Name; /** * Provides the implementation of the {@link ParlorService} interface @@ -18,10 +19,6 @@ import com.threerings.presents.dobj.InvocationResponseEvent; * on the server. Also provides an implementation of the response listener * interfaces that marshall the response arguments and deliver them back * to the requesting client. - * - *

Generated from - * $Id: ParlorMarshaller.java,v 1.2 2002/08/20 19:38:14 mdb Exp $ - * */ public class ParlorMarshaller extends InvocationMarshaller implements ParlorService @@ -92,7 +89,7 @@ public class ParlorMarshaller extends InvocationMarshaller public static final int INVITE = 1; // documentation inherited from interface - public void invite (Client arg1, String arg2, GameConfig arg3, InviteListener arg4) + public void invite (Client arg1, Name arg2, GameConfig arg3, InviteListener arg4) { InviteMarshaller listener4 = new InviteMarshaller(); listener4.listener = arg4; @@ -166,5 +163,4 @@ public class ParlorMarshaller extends InvocationMarshaller }); } - // Class file generated on 12:33:04 08/20/02. } diff --git a/src/java/com/threerings/parlor/data/Table.java b/src/java/com/threerings/parlor/data/Table.java index d81a9d360..f0637bf40 100644 --- a/src/java/com/threerings/parlor/data/Table.java +++ b/src/java/com/threerings/parlor/data/Table.java @@ -1,9 +1,10 @@ // -// $Id: Table.java,v 1.16 2003/03/27 23:45:04 mdb Exp $ +// $Id: Table.java,v 1.17 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.data; import com.samskivert.util.StringUtil; +import com.threerings.util.Name; import com.threerings.presents.dobj.DSet; @@ -30,7 +31,7 @@ public class Table /** An array of the usernames of the occupants of this table (some * slots may not be filled). */ - public String[] occupants; + public Name[] occupants; /** The body oids of the occupants of this table. (This is not * propagated to remote instances.) */ @@ -64,7 +65,7 @@ public class Table this.config = config; // make room for the maximum number of players - occupants = new String[_tconfig.getMaximumPlayers()]; + occupants = new Name[_tconfig.getMaximumPlayers()]; bodyOids = new int[occupants.length]; } @@ -90,21 +91,21 @@ public class Table * the players in the game, sized properly and with each player in the * appropriate position. */ - public String[] getPlayers () + public Name[] getPlayers () { // count up the players int pcount = 0; for (int i = 0; i < occupants.length; i++) { - if (!StringUtil.blank(occupants[i])) { + if (occupants[i] != null) { pcount++; } } // create and populate the players array - String[] players = new String[pcount]; + Name[] players = new Name[pcount]; pcount = 0; for (int i = 0; i < occupants.length; i++) { - if (!StringUtil.blank(occupants[i])) { + if (occupants[i] != null) { players[pcount++] = occupants[i]; } } @@ -124,7 +125,7 @@ public class Table * code explaining the failure if the user was not able to be seated * at that position. */ - public String setOccupant (int position, String username, int bodyOid) + public String setOccupant (int position, Name username, int bodyOid) { // find out how many positions we have for occupation int maxpos = _tconfig.getDesiredPlayers(); @@ -139,7 +140,7 @@ public class Table } // make sure the requested position is not already occupied - if (!StringUtil.blank(occupants[position])) { + if (occupants[position] != null) { return TABLE_POSITION_OCCUPIED; } @@ -157,11 +158,11 @@ public class Table * removed, false if the user was never seated at the table in the * first place. */ - public boolean clearOccupant (String username) + public boolean clearOccupant (Name username) { for (int i = 0; i < occupants.length; i++) { if (username.equals(occupants[i])) { - occupants[i] = ""; + occupants[i] = null; bodyOids[i] = 0; return true; } @@ -181,7 +182,7 @@ public class Table { for (int i = 0; i < bodyOids.length; i++) { if (bodyOid == bodyOids[i]) { - occupants[i] = ""; + occupants[i] = null; bodyOids[i] = 0; return true; } @@ -198,7 +199,7 @@ public class Table // make sure at least the minimum number of players are here int want = _tconfig.getMinimumPlayers(), have = 0; for (int i = 0; i < occupants.length; i++) { - if (!StringUtil.blank(occupants[i])) { + if (occupants[i] != null) { if (++have == want) { return true; } @@ -218,10 +219,8 @@ public class Table need = _tconfig.getMaximumPlayers(); } for (int i = 0; i < occupants.length; i++) { - if (StringUtil.blank(occupants[i])) { - if (--need == 0) { - return true; - } + if (occupants[i] != null && --need == 0) { + return true; } } return false; @@ -233,7 +232,7 @@ public class Table public boolean isEmpty () { for (int i = 0; i < occupants.length; i++) { - if (!StringUtil.blank(occupants[i])) { + if (occupants[i] != null) { return false; } } diff --git a/src/java/com/threerings/parlor/game/GameConfig.java b/src/java/com/threerings/parlor/game/GameConfig.java index c91a045d0..a287995ee 100644 --- a/src/java/com/threerings/parlor/game/GameConfig.java +++ b/src/java/com/threerings/parlor/game/GameConfig.java @@ -1,9 +1,10 @@ // -// $Id: GameConfig.java,v 1.16 2004/02/25 14:44:54 mdb Exp $ +// $Id: GameConfig.java,v 1.17 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.game; import com.threerings.crowd.data.PlaceConfig; +import com.threerings.util.Name; /** * The game config class encapsulates the configuration information for a @@ -26,7 +27,7 @@ public abstract class GameConfig extends PlaceConfig { /** The usernames of the players involved in this game, or an empty * array if such information is not needed by this particular game. */ - public String[] players = new String[0]; + public Name[] players = new Name[0]; /** Indicates whether or not this game is rated. */ public boolean rated = true; diff --git a/src/java/com/threerings/parlor/game/GameManager.java b/src/java/com/threerings/parlor/game/GameManager.java index a4240a6c3..ca6e6707d 100644 --- a/src/java/com/threerings/parlor/game/GameManager.java +++ b/src/java/com/threerings/parlor/game/GameManager.java @@ -1,5 +1,5 @@ // -// $Id: GameManager.java,v 1.70 2004/02/25 14:44:54 mdb Exp $ +// $Id: GameManager.java,v 1.71 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.game; @@ -9,6 +9,7 @@ import java.util.Iterator; import com.samskivert.util.IntervalManager; import com.samskivert.util.StringUtil; +import com.threerings.util.Name; import com.threerings.presents.data.ClientObject; import com.threerings.presents.dobj.AttributeChangeListener; @@ -18,9 +19,8 @@ import com.threerings.presents.server.util.SafeInterval; import com.threerings.crowd.chat.server.SpeakProvider; import com.threerings.crowd.data.BodyObject; - -import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.server.CrowdServer; +import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.server.PlaceManagerDelegate; import com.threerings.parlor.Log; @@ -79,7 +79,7 @@ public class GameManager extends PlaceManager * @return the player index at which the player was added, or * -1 if the player could not be added to the game. */ - public int addPlayer (String player) + public int addPlayer (Name player) { // determine the first available player index int pidx = -1; @@ -112,7 +112,7 @@ public class GameManager extends PlaceManager * @param pidx the player index at which the player is to be added. * @return true if the player was added successfully, false if not. */ - public boolean addPlayerAt (String player, int pidx) + public boolean addPlayerAt (Name player, int pidx) { // make sure the specified player index is valid if (pidx < 0 || pidx >= getPlayerSlots()) { @@ -173,7 +173,7 @@ public class GameManager extends PlaceManager * @param player the username of the player added to the game. * @param pidx the player index of the player added to the game. */ - protected void playerWasAdded (String player, int pidx) + protected void playerWasAdded (Name player, int pidx) { } @@ -185,7 +185,7 @@ public class GameManager extends PlaceManager * @param player the username of the player to remove from this game. * @return true if the player was successfully removed, false if not. */ - public boolean removePlayer (String player) + public boolean removePlayer (Name player) { // get the player's index in the player list int pidx = _gameobj.getPlayerIndex(player); @@ -230,7 +230,7 @@ public class GameManager extends PlaceManager * @param pidx the player index of the player before they were removed * from the game. */ - protected void playerWasRemoved (String player, int pidx) + protected void playerWasRemoved (Name player, int pidx) { } @@ -265,18 +265,19 @@ public class GameManager extends PlaceManager } /** - * Returns the name of the player with the specified index. + * Returns the name of the player with the specified index or null if + * no player exists at that index. */ - public String getPlayerName (int index) + public Name getPlayerName (int index) { - return (_gameobj == null) ? "" : _gameobj.players[index]; + return (_gameobj == null) ? null : _gameobj.players[index]; } /** * Returns the player index of the given user in the game, or * -1 if the player is not involved in the game. */ - public int getPlayerIndex (String username) + public int getPlayerIndex (Name username) { return (_gameobj == null) ? -1 : _gameobj.getPlayerIndex(username); } diff --git a/src/java/com/threerings/parlor/game/GameObject.dobj b/src/java/com/threerings/parlor/game/GameObject.dobj index ee3c92b8b..cfe106b39 100644 --- a/src/java/com/threerings/parlor/game/GameObject.dobj +++ b/src/java/com/threerings/parlor/game/GameObject.dobj @@ -1,10 +1,11 @@ // -// $Id: GameObject.dobj,v 1.20 2003/05/26 23:46:46 mdb Exp $ +// $Id: GameObject.dobj,v 1.21 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.game; import com.samskivert.util.ListUtil; import com.samskivert.util.StringUtil; +import com.threerings.util.Name; import com.threerings.crowd.data.PlaceObject; @@ -44,7 +45,7 @@ public class GameObject extends PlaceObject public boolean isRated; /** The usernames of the players involved in this game. */ - public String[] players; + public Name[] players; /** Whether each player in the game is a winner, or null * if the game is not yet over. */ @@ -75,7 +76,7 @@ public class GameObject extends PlaceObject * Returns the player index of the given user in the game, or * -1 if the player is not involved in the game. */ - public int getPlayerIndex (String username) + public int getPlayerIndex (Name username) { int size = (players == null) ? 0 : players.length; for (int ii = 0; ii < size; ii++) { diff --git a/src/java/com/threerings/parlor/game/GameObject.java b/src/java/com/threerings/parlor/game/GameObject.java index aa9010be5..b8bccbd5a 100644 --- a/src/java/com/threerings/parlor/game/GameObject.java +++ b/src/java/com/threerings/parlor/game/GameObject.java @@ -1,9 +1,11 @@ // -// $Id: GameObject.java,v 1.17 2004/02/25 14:44:54 mdb Exp $ +// $Id: GameObject.java,v 1.18 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.game; +import com.samskivert.util.ListUtil; import com.samskivert.util.StringUtil; +import com.threerings.util.Name; import com.threerings.crowd.data.PlaceObject; @@ -64,7 +66,7 @@ public class GameObject extends PlaceObject public boolean isRated; /** The usernames of the players involved in this game. */ - public String[] players; + public Name[] players; /** Whether each player in the game is a winner, or null * if the game is not yet over. */ @@ -95,7 +97,7 @@ public class GameObject extends PlaceObject * Returns the player index of the given user in the game, or * -1 if the player is not involved in the game. */ - public int getPlayerIndex (String username) + public int getPlayerIndex (Name username) { int size = (players == null) ? 0 : players.length; for (int ii = 0; ii < size; ii++) { @@ -223,7 +225,7 @@ public class GameObject extends PlaceObject * clients) will apply the value change when they received the * attribute changed notification. */ - public void setPlayers (String[] players) + public void setPlayers (Name[] players) { requestAttributeChange(PLAYERS, players); this.players = players; @@ -237,7 +239,7 @@ public class GameObject extends PlaceObject * change. Proxied copies of this object (on clients) will apply the * value change when they received the attribute changed notification. */ - public void setPlayersAt (String value, int index) + public void setPlayersAt (Name value, int index) { requestElementUpdate(PLAYERS, value, index); this.players[index] = value; diff --git a/src/java/com/threerings/parlor/server/ParlorDispatcher.java b/src/java/com/threerings/parlor/server/ParlorDispatcher.java index dec7e35b6..3da48076c 100644 --- a/src/java/com/threerings/parlor/server/ParlorDispatcher.java +++ b/src/java/com/threerings/parlor/server/ParlorDispatcher.java @@ -1,5 +1,5 @@ // -// $Id: ParlorDispatcher.java,v 1.2 2002/08/20 19:38:14 mdb Exp $ +// $Id: ParlorDispatcher.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.server; @@ -14,13 +14,10 @@ import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller; import com.threerings.presents.server.InvocationDispatcher; import com.threerings.presents.server.InvocationException; +import com.threerings.util.Name; /** * Dispatches requests to the {@link ParlorProvider}. - * - *

Generated from - * $Id: ParlorDispatcher.java,v 1.2 2002/08/20 19:38:14 mdb Exp $ - * */ public class ParlorDispatcher extends InvocationDispatcher { @@ -48,7 +45,7 @@ public class ParlorDispatcher extends InvocationDispatcher case ParlorMarshaller.INVITE: ((ParlorProvider)provider).invite( source, - (String)args[0], (GameConfig)args[1], (InviteListener)args[2] + (Name)args[0], (GameConfig)args[1], (InviteListener)args[2] ); return; diff --git a/src/java/com/threerings/parlor/server/ParlorManager.java b/src/java/com/threerings/parlor/server/ParlorManager.java index 401cbbcaa..9712e8c31 100644 --- a/src/java/com/threerings/parlor/server/ParlorManager.java +++ b/src/java/com/threerings/parlor/server/ParlorManager.java @@ -1,9 +1,10 @@ // -// $Id: ParlorManager.java,v 1.20 2002/10/06 00:53:15 mdb Exp $ +// $Id: ParlorManager.java,v 1.21 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.server; import com.samskivert.util.HashIntMap; +import com.threerings.util.Name; import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationManager; @@ -183,7 +184,7 @@ public class ParlorManager Log.info("Creating game manager [invite=" + invite + "]."); // configure the game config with the player info - invite.config.players = new String[] { + invite.config.players = new Name[] { invite.invitee.username, invite.inviter.username }; // create the game manager and begin it's initialization diff --git a/src/java/com/threerings/parlor/server/ParlorProvider.java b/src/java/com/threerings/parlor/server/ParlorProvider.java index a580b25e8..46bc3c627 100644 --- a/src/java/com/threerings/parlor/server/ParlorProvider.java +++ b/src/java/com/threerings/parlor/server/ParlorProvider.java @@ -1,8 +1,10 @@ // -// $Id: ParlorProvider.java,v 1.13 2002/08/14 19:07:54 mdb Exp $ +// $Id: ParlorProvider.java,v 1.14 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.server; +import com.threerings.util.Name; + import com.threerings.presents.client.InvocationService.InvocationListener; import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationException; @@ -44,7 +46,7 @@ public class ParlorProvider * Processes a request from the client to invite another user to play * a game. */ - public void invite (ClientObject caller, String invitee, + public void invite (ClientObject caller, Name invitee, GameConfig config, InviteListener listener) throws InvocationException { diff --git a/src/java/com/threerings/parlor/server/ParlorSender.java b/src/java/com/threerings/parlor/server/ParlorSender.java index 03f7924e2..16905a8af 100644 --- a/src/java/com/threerings/parlor/server/ParlorSender.java +++ b/src/java/com/threerings/parlor/server/ParlorSender.java @@ -1,5 +1,5 @@ // -// $Id: ParlorSender.java,v 1.2 2002/08/20 19:38:14 mdb Exp $ +// $Id: ParlorSender.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.server; @@ -8,14 +8,11 @@ import com.threerings.parlor.client.ParlorReceiver; import com.threerings.parlor.game.GameConfig; import com.threerings.presents.data.ClientObject; import com.threerings.presents.server.InvocationSender; +import com.threerings.util.Name; /** * Used to issue notifications to a {@link ParlorReceiver} instance on a * client. - * - *

Generated from - * $Id: ParlorSender.java,v 1.2 2002/08/20 19:38:14 mdb Exp $ - * */ public class ParlorSender extends InvocationSender { @@ -36,7 +33,7 @@ public class ParlorSender extends InvocationSender * ParlorReceiver#receivedInvite} on a client. */ public static void sendInvite ( - ClientObject target, int arg1, String arg2, GameConfig arg3) + ClientObject target, int arg1, Name arg2, GameConfig arg3) { sendNotification( target, ParlorDecoder.RECEIVER_CODE, ParlorDecoder.RECEIVED_INVITE, @@ -67,5 +64,4 @@ public class ParlorSender extends InvocationSender new Object[] { new Integer(arg1) }); } - // Generated on 12:37:00 08/20/02. } diff --git a/src/java/com/threerings/parlor/server/TableManager.java b/src/java/com/threerings/parlor/server/TableManager.java index ed0fbc464..3cc25856b 100644 --- a/src/java/com/threerings/parlor/server/TableManager.java +++ b/src/java/com/threerings/parlor/server/TableManager.java @@ -1,5 +1,5 @@ // -// $Id: TableManager.java,v 1.9 2003/03/27 23:45:04 mdb Exp $ +// $Id: TableManager.java,v 1.10 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.server; @@ -8,6 +8,7 @@ import java.util.Iterator; import com.samskivert.util.HashIntMap; import com.samskivert.util.StringUtil; +import com.threerings.util.Name; import com.threerings.presents.dobj.ObjectAddedEvent; import com.threerings.presents.dobj.ObjectDeathListener; @@ -254,8 +255,7 @@ public class TableManager * @return a reference to the newly created game manager or null if * something choked during the creation or initialization process. */ - protected GameManager createGameManager ( - GameConfig config, String[] players) + protected GameManager createGameManager (GameConfig config, Name[] players) { GameManager gmgr = null; diff --git a/src/java/com/threerings/parlor/turn/TurnGameManager.java b/src/java/com/threerings/parlor/turn/TurnGameManager.java index 7cd180236..6c2a6e398 100644 --- a/src/java/com/threerings/parlor/turn/TurnGameManager.java +++ b/src/java/com/threerings/parlor/turn/TurnGameManager.java @@ -1,8 +1,10 @@ // -// $Id: TurnGameManager.java,v 1.9 2004/02/25 14:44:54 mdb Exp $ +// $Id: TurnGameManager.java,v 1.10 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.turn; +import com.threerings.util.Name; + /** * A game manager that wishes to make use of the turn game services should * implement this interface and create a {@link TurnGameManagerDelegate} @@ -30,13 +32,13 @@ public interface TurnGameManager * Extending {@link GameManager} should automatically handle * implementing this method. */ - public String getPlayerName (int index); + public Name getPlayerName (int index); /** * Extending {@link GameManager} should automatically handle * implementing this method. */ - public int getPlayerIndex (String username); + public int getPlayerIndex (Name username); /** * Extending {@link GameManager} should automatically handle diff --git a/src/java/com/threerings/parlor/turn/TurnGameManagerDelegate.java b/src/java/com/threerings/parlor/turn/TurnGameManagerDelegate.java index 222fc2d2f..28ead99a5 100644 --- a/src/java/com/threerings/parlor/turn/TurnGameManagerDelegate.java +++ b/src/java/com/threerings/parlor/turn/TurnGameManagerDelegate.java @@ -1,14 +1,16 @@ // -// $Id: TurnGameManagerDelegate.java,v 1.8 2002/10/15 23:07:23 shaper Exp $ +// $Id: TurnGameManagerDelegate.java,v 1.9 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.turn; +import com.threerings.util.Name; +import com.threerings.util.RandomUtil; + import com.threerings.crowd.data.PlaceObject; import com.threerings.parlor.Log; import com.threerings.parlor.game.GameManager; import com.threerings.parlor.game.GameManagerDelegate; -import com.threerings.util.RandomUtil; /** * Performs the server-side turn-based game processing for a turn based @@ -40,7 +42,6 @@ public class TurnGameManagerDelegate extends GameManagerDelegate */ public int getTurnHolderIndex () { - String holder = _turnGame.getTurnHolder(); return _tgmgr.getPlayerIndex(_turnGame.getTurnHolder()); } @@ -67,7 +68,7 @@ public class TurnGameManagerDelegate extends GameManagerDelegate } // get the player name and sanity-check again - String name = _tgmgr.getPlayerName(_turnIdx); + Name name = _tgmgr.getPlayerName(_turnIdx); if (name == null) { Log.warning("startTurn() called with invalid player " + "[turnIdx=" + _turnIdx + "]."); diff --git a/src/java/com/threerings/parlor/turn/TurnGameObject.java b/src/java/com/threerings/parlor/turn/TurnGameObject.java index a45e7bc89..ff93bdbdd 100644 --- a/src/java/com/threerings/parlor/turn/TurnGameObject.java +++ b/src/java/com/threerings/parlor/turn/TurnGameObject.java @@ -1,8 +1,10 @@ // -// $Id: TurnGameObject.java,v 1.5 2004/02/25 14:44:54 mdb Exp $ +// $Id: TurnGameObject.java,v 1.6 2004/03/06 11:29:19 mdb Exp $ package com.threerings.parlor.turn; +import com.threerings.util.Name; + /** * Games that wish to support turn-based play must implement this * interface with their {@link GameObject}. @@ -21,16 +23,16 @@ public interface TurnGameObject * turn in this turn-based game or null if no user * currently holds the turn. */ - public String getTurnHolder (); + public Name getTurnHolder (); /** * Requests that the turnHolder field be set to the specified * value. */ - public void setTurnHolder (String turnHolder); + public void setTurnHolder (Name turnHolder); /** * Returns the array of player names involved in the game. */ - public String[] getPlayers (); + public Name[] getPlayers (); } diff --git a/src/java/com/threerings/presents/net/Credentials.java b/src/java/com/threerings/presents/net/Credentials.java index ebd4234bc..e0ec1bc05 100644 --- a/src/java/com/threerings/presents/net/Credentials.java +++ b/src/java/com/threerings/presents/net/Credentials.java @@ -1,9 +1,10 @@ // -// $Id: Credentials.java,v 1.12 2004/01/31 12:16:12 mdb Exp $ +// $Id: Credentials.java,v 1.13 2004/03/06 11:29:19 mdb Exp $ package com.threerings.presents.net; import com.threerings.io.Streamable; +import com.threerings.util.Name; /** * Credentials are supplied by the client implementation and sent along to @@ -24,7 +25,7 @@ public abstract class Credentials implements Streamable /** * Constructs a credentials instance with the specified username. */ - public Credentials (String username) + public Credentials (Name username) { _username = username; } @@ -37,7 +38,7 @@ public abstract class Credentials implements Streamable { } - public String getUsername () + public Name getUsername () { return _username; } @@ -77,5 +78,5 @@ public abstract class Credentials implements Streamable buf.append("username=").append(_username); } - protected String _username; + protected Name _username; } diff --git a/src/java/com/threerings/presents/net/UsernamePasswordCreds.java b/src/java/com/threerings/presents/net/UsernamePasswordCreds.java index c48d60eec..693605417 100644 --- a/src/java/com/threerings/presents/net/UsernamePasswordCreds.java +++ b/src/java/com/threerings/presents/net/UsernamePasswordCreds.java @@ -1,8 +1,10 @@ // -// $Id: UsernamePasswordCreds.java,v 1.12 2004/01/31 12:16:12 mdb Exp $ +// $Id: UsernamePasswordCreds.java,v 1.13 2004/03/06 11:29:19 mdb Exp $ package com.threerings.presents.net; +import com.threerings.util.Name; + public class UsernamePasswordCreds extends Credentials { /** @@ -16,7 +18,7 @@ public class UsernamePasswordCreds extends Credentials /** * Construct credentials with the supplied username and password. */ - public UsernamePasswordCreds (String username, String password) + public UsernamePasswordCreds (Name username, String password) { super(username); _password = password; diff --git a/src/java/com/threerings/presents/server/ClientManager.java b/src/java/com/threerings/presents/server/ClientManager.java index 0138c8697..c8c94baff 100644 --- a/src/java/com/threerings/presents/server/ClientManager.java +++ b/src/java/com/threerings/presents/server/ClientManager.java @@ -1,5 +1,5 @@ // -// $Id: ClientManager.java,v 1.35 2004/02/21 01:00:23 ray Exp $ +// $Id: ClientManager.java,v 1.36 2004/03/06 11:29:19 mdb Exp $ package com.threerings.presents.server; @@ -12,6 +12,8 @@ import java.util.Iterator; import com.samskivert.util.IntervalManager; import com.samskivert.util.StringUtil; +import com.threerings.util.Name; + import com.threerings.presents.Log; import com.threerings.presents.data.ClientObject; import com.threerings.presents.net.AuthRequest; @@ -143,9 +145,9 @@ public class ClientManager * specified authentication username or null if that client is not * currently connected to the server. */ - public PresentsClient getClient (String authUsername) + public PresentsClient getClient (Name authUsername) { - return (PresentsClient)_usermap.get(authUsername.toLowerCase()); + return (PresentsClient)_usermap.get(authUsername); } /** @@ -153,26 +155,16 @@ public class ClientManager * This will return null unless the client object is resolved for some * reason (like they are logged on). */ - public ClientObject getClientObject (String username) + public ClientObject getClientObject (Name username) { - return (ClientObject)_objmap.get(toKey(username)); - } - - /** - * We convert usernames to lower case in the username to client object - * mapping so that we can pass arbitrarily cased usernames (like those - * that might be typed in by a "user") straight on through. - */ - protected final String toKey (String username) - { - return username.toLowerCase(); + return (ClientObject)_objmap.get(username); } /** * Resolves the specified client, applies the supplied client * operation to them and releases the client. */ - public void applyToClient (String username, ClientOp clop) + public void applyToClient (Name username, ClientOp clop) { resolveClientObject(username, new ClientOpResolver(clop)); } @@ -187,11 +179,10 @@ public class ClientManager * when the caller is finished with the client object. */ public synchronized void resolveClientObject ( - String username, ClientResolutionListener listener) + Name username, ClientResolutionListener listener) { // look to see if the client object is already resolved - String key = toKey(username); - ClientObject clobj = (ClientObject)_objmap.get(key); + ClientObject clobj = (ClientObject)_objmap.get(username); if (clobj != null) { clobj.reference(); listener.clientResolved(username, clobj); @@ -199,7 +190,7 @@ public class ClientManager } // look to see if it's currently being resolved - ClientResolver clr = (ClientResolver)_penders.get(key); + ClientResolver clr = (ClientResolver)_penders.get(username); if (clr != null) { // throw this guy onto the bandwagon clr.addResolutionListener(listener); @@ -228,14 +219,13 @@ public class ClientManager * resolved. */ protected synchronized void mapClientObject ( - String username, ClientObject clobj) + Name username, ClientObject clobj) { // stuff the object into the mapping table - String key = toKey(username); - _objmap.put(key, clobj); + _objmap.put(username, clobj); // and remove the resolution listener - _penders.remove(key); + _penders.remove(username); } /** @@ -243,10 +233,9 @@ public class ClientManager * #resolveClientObject}. If this caller is the last reference, the * object will be flushed and destroyed. */ - public void releaseClientObject (String username) + public void releaseClientObject (Name username) { - String key = toKey(username); - ClientObject clobj = (ClientObject)_objmap.get(key); + ClientObject clobj = (ClientObject)_objmap.get(username); if (clobj == null) { Log.warning("Requested to release unmapped client object " + "[username=" + username + "]."); @@ -263,7 +252,7 @@ public class ClientManager Log.debug("Destroying client " + clobj.who() + "."); // we're all clear to go; remove the mapping - _objmap.remove(key); + _objmap.remove(username); // and destroy the object itself PresentsServer.omgr.destroyObject(clobj.getOid()); @@ -274,7 +263,7 @@ public class ClientManager Connection conn, AuthRequest req, AuthResponse rsp) { Credentials creds = req.getCredentials(); - String username = creds.getUsername().toLowerCase(); + Name username = creds.getUsername(); // see if a client is already registered with these credentials PresentsClient client = getClient(username); @@ -378,12 +367,10 @@ public class ClientManager */ synchronized void clientDidEndSession (PresentsClient client) { - Credentials creds = client.getCredentials(); - String username = client.getUsername(); - // remove the client from the username map + Credentials creds = client.getCredentials(); PresentsClient rc = (PresentsClient) - _usermap.remove(creds.getUsername().toLowerCase()); + _usermap.remove(creds.getUsername()); // sanity check just because we can if (rc == null) { @@ -440,7 +427,7 @@ public class ClientManager } // documentation inherited from interface - public void clientResolved (String username, ClientObject clobj) + public void clientResolved (Name username, ClientObject clobj) { try { _clop.apply(clobj); @@ -456,7 +443,7 @@ public class ClientManager } // documentation inherited from interface - public void resolutionFailed (String username, Exception reason) + public void resolutionFailed (Name username, Exception reason) { _clop.resolutionFailed(reason); } diff --git a/src/java/com/threerings/presents/server/ClientResolutionListener.java b/src/java/com/threerings/presents/server/ClientResolutionListener.java index b88fe92b5..e4d02ad03 100644 --- a/src/java/com/threerings/presents/server/ClientResolutionListener.java +++ b/src/java/com/threerings/presents/server/ClientResolutionListener.java @@ -1,9 +1,10 @@ // -// $Id: ClientResolutionListener.java,v 1.2 2002/11/29 23:40:01 mdb Exp $ +// $Id: ClientResolutionListener.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.presents.server; import com.threerings.presents.data.ClientObject; +import com.threerings.util.Name; /** * Entites that wish to resolve client objects must implement this @@ -15,10 +16,10 @@ public interface ClientResolutionListener /** * Called when resolution completed successfully. */ - public void clientResolved (String username, ClientObject clobj); + public void clientResolved (Name username, ClientObject clobj); /** * Called when resolution fails. */ - public void resolutionFailed (String username, Exception reason); + public void resolutionFailed (Name username, Exception reason); } diff --git a/src/java/com/threerings/presents/server/ClientResolver.java b/src/java/com/threerings/presents/server/ClientResolver.java index a95937f81..b9346315b 100644 --- a/src/java/com/threerings/presents/server/ClientResolver.java +++ b/src/java/com/threerings/presents/server/ClientResolver.java @@ -1,10 +1,12 @@ // -// $Id: ClientResolver.java,v 1.3 2002/11/26 08:52:53 mdb Exp $ +// $Id: ClientResolver.java,v 1.4 2004/03/06 11:29:19 mdb Exp $ package com.threerings.presents.server; import java.util.ArrayList; +import com.threerings.util.Name; + import com.threerings.presents.Log; import com.threerings.presents.data.ClientObject; import com.threerings.presents.dobj.DObject; @@ -27,7 +29,7 @@ public class ClientResolver extends Invoker.Unit * * @param username the username of the user to be resolved. */ - public void init (String username) + public void init (Name username) { _username = username; } @@ -151,7 +153,7 @@ public class ClientResolver extends Invoker.Unit } /** The name of the user whose client object is being resolved. */ - protected String _username; + protected Name _username; /** The entities to notify of success or failure. */ protected ArrayList _listeners = new ArrayList(); diff --git a/src/java/com/threerings/presents/server/PresentsClient.java b/src/java/com/threerings/presents/server/PresentsClient.java index 46e21ac37..4ee1a5cdf 100644 --- a/src/java/com/threerings/presents/server/PresentsClient.java +++ b/src/java/com/threerings/presents/server/PresentsClient.java @@ -1,5 +1,5 @@ // -// $Id: PresentsClient.java,v 1.64 2004/02/22 18:52:33 ray Exp $ +// $Id: PresentsClient.java,v 1.65 2004/03/06 11:29:19 mdb Exp $ package com.threerings.presents.server; @@ -10,6 +10,7 @@ import java.util.Iterator; import com.samskivert.util.HashIntMap; import com.samskivert.util.Throttle; +import com.threerings.util.Name; import com.threerings.presents.Log; import com.threerings.presents.data.ClientObject; @@ -113,7 +114,7 @@ public class PresentsClient /** * Returns the username with which this client instance is associated. */ - public String getUsername () + public Name getUsername () { return _username; } @@ -149,10 +150,10 @@ public class PresentsClient * @param ucl an entity that will (optionally) be notified when the * username conversion process is complete. */ - public void setUsername (String username, final UserChangeListener ucl) + public void setUsername (Name username, final UserChangeListener ucl) { ClientResolutionListener clr = new ClientResolutionListener() { - public void clientResolved (String username, ClientObject clobj) { + public void clientResolved (Name username, ClientObject clobj) { // if they old client object is gone by now, they ended // their session while we were switching, so freak out if (_clobj == null) { @@ -195,7 +196,7 @@ public class PresentsClient } } - public void resolutionFailed (String username, Exception reason) { + public void resolutionFailed (Name username, Exception reason) { Log.warning("Unable to resolve new client object " + "[oldname=" + _username + ", newname=" + username + ", reason=" + reason + "]."); @@ -274,7 +275,7 @@ public class PresentsClient } // documentation inherited from interface - public void clientResolved (String username, ClientObject clobj) + public void clientResolved (Name username, ClientObject clobj) { // we'll be keeping this bad boy _clobj = clobj; @@ -285,7 +286,7 @@ public class PresentsClient } // documentation inherited from interface - public void resolutionFailed (String username, Exception reason) + public void resolutionFailed (Name username, Exception reason) { // urk; nothing to do but complain and get the f**k out of dodge Log.warning("Unable to resolve client [username=" + username + "]."); @@ -863,7 +864,7 @@ public class PresentsClient protected ClientManager _cmgr; protected Credentials _creds; - protected String _username; + protected Name _username; protected Connection _conn; protected ClientObject _clobj; protected HashIntMap _subscrips = new HashIntMap(); diff --git a/src/java/com/threerings/puzzle/client/PlayerStatusView.java b/src/java/com/threerings/puzzle/client/PlayerStatusView.java index 3355015f7..6f698e61a 100644 --- a/src/java/com/threerings/puzzle/client/PlayerStatusView.java +++ b/src/java/com/threerings/puzzle/client/PlayerStatusView.java @@ -1,10 +1,12 @@ // -// $Id: PlayerStatusView.java,v 1.2 2004/02/25 14:48:44 mdb Exp $ +// $Id: PlayerStatusView.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.puzzle.client; import javax.swing.JPanel; +import com.threerings.util.Name; + import com.threerings.parlor.game.GameObject; import com.threerings.puzzle.data.BoardSummary; @@ -84,7 +86,7 @@ public class PlayerStatusView extends JPanel protected GameObject _gameobj; /** The player name. */ - protected String _username; + protected Name _username; /** The player index. */ protected int _pidx; diff --git a/src/java/com/threerings/puzzle/server/PuzzleManager.java b/src/java/com/threerings/puzzle/server/PuzzleManager.java index a57d85f3e..22bf39fbf 100644 --- a/src/java/com/threerings/puzzle/server/PuzzleManager.java +++ b/src/java/com/threerings/puzzle/server/PuzzleManager.java @@ -1,5 +1,5 @@ // -// $Id: PuzzleManager.java,v 1.7 2004/02/25 14:48:44 mdb Exp $ +// $Id: PuzzleManager.java,v 1.8 2004/03/06 11:29:19 mdb Exp $ package com.threerings.puzzle.server; @@ -22,6 +22,7 @@ import com.threerings.crowd.server.PlaceManagerDelegate; import com.threerings.parlor.game.GameManager; import com.threerings.util.MessageBundle; +import com.threerings.util.Name; import com.threerings.util.RandomUtil; import com.threerings.puzzle.Log; @@ -62,7 +63,7 @@ public abstract class PuzzleManager extends GameManager return (BodyObject)CrowdServer.omgr.getObject(ploid); } // otherwise look them up by name - String name = getPlayerName(playerIdx); + Name name = getPlayerName(playerIdx); return (name == null) ? null : CrowdServer.lookupBody(name); } diff --git a/src/java/com/threerings/puzzle/server/PuzzleProvider.java b/src/java/com/threerings/puzzle/server/PuzzleProvider.java index b6fd33550..ea135fdff 100644 --- a/src/java/com/threerings/puzzle/server/PuzzleProvider.java +++ b/src/java/com/threerings/puzzle/server/PuzzleProvider.java @@ -1,8 +1,10 @@ // -// $Id: PuzzleProvider.java,v 1.2 2004/02/25 14:48:44 mdb Exp $ +// $Id: PuzzleProvider.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.puzzle.server; +import com.threerings.util.Name; + import com.threerings.presents.client.InvocationService.InvocationListener; import com.threerings.presents.data.ClientObject; import com.threerings.presents.dobj.RootDObjectManager; @@ -54,7 +56,7 @@ public class PuzzleProvider try { // just this fellow will be playing - config.players = new String[] { user.username }; + config.players = new Name[] { user.username }; // create the game manager and begin its initialization // process diff --git a/src/java/com/threerings/puzzle/util/PuzzleContext.java b/src/java/com/threerings/puzzle/util/PuzzleContext.java index eb4edf482..b2fb23c5e 100644 --- a/src/java/com/threerings/puzzle/util/PuzzleContext.java +++ b/src/java/com/threerings/puzzle/util/PuzzleContext.java @@ -1,11 +1,12 @@ // -// $Id: PuzzleContext.java,v 1.3 2003/11/26 23:16:13 mdb Exp $ +// $Id: PuzzleContext.java,v 1.4 2004/03/06 11:29:19 mdb Exp $ package com.threerings.puzzle.util; import com.threerings.util.KeyDispatcher; import com.threerings.util.KeyboardManager; import com.threerings.util.MessageManager; +import com.threerings.util.Name; import com.threerings.media.FrameManager; import com.threerings.media.sound.SoundManager; @@ -21,7 +22,7 @@ public interface PuzzleContext extends ParlorContext /** * Returns the username of the local user. */ - public String getUsername (); + public Name getUsername (); /** * Returns a reference to the message manager used by the client. diff --git a/src/java/com/threerings/resource/Downloader.java b/src/java/com/threerings/resource/Downloader.java index 1b090c158..29f93c1ae 100644 --- a/src/java/com/threerings/resource/Downloader.java +++ b/src/java/com/threerings/resource/Downloader.java @@ -1,5 +1,5 @@ // -// $Id: Downloader.java,v 1.2 2003/08/05 07:03:34 mdb Exp $ +// $Id: Downloader.java,v 1.3 2004/03/06 11:29:19 mdb Exp $ package com.threerings.resource; @@ -112,6 +112,10 @@ public abstract class Downloader FileOutputStream out = new FileOutputStream(destFile); int read; + // TODO: look to see if we have a download info file containing + // info on potentially partially downloaded data; if so, use a + // "Range: bytes=HAVE-" header. + // read in the file data while ((read = in.read(buffer)) != -1) { // write it out to our local copy diff --git a/src/java/com/threerings/util/MessageBundle.java b/src/java/com/threerings/util/MessageBundle.java index 3e48797f5..d13d5b4d5 100644 --- a/src/java/com/threerings/util/MessageBundle.java +++ b/src/java/com/threerings/util/MessageBundle.java @@ -1,5 +1,5 @@ // -// $Id: MessageBundle.java,v 1.24 2004/02/05 17:39:03 mdb Exp $ +// $Id: MessageBundle.java,v 1.25 2004/03/06 11:29:19 mdb Exp $ package com.threerings.util; @@ -266,7 +266,7 @@ public class MessageBundle * attempt to translate this string when doing recursive translations * (see {@link #xlate}). */ - public static String taint (String text) + public static String taint (Object text) { return MessageUtil.taint(text); } @@ -275,77 +275,77 @@ public class MessageBundle * Composes a message key with an array of arguments. The message can * subsequently be translated in a single call using {@link #xlate}. */ - public static String compose (String key, String[] args) + public static String compose (String key, Object[] args) { return MessageUtil.compose(key, args); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with a single argument. */ - public static String compose (String key, String arg) + public static String compose (String key, Object arg) { - return compose(key, new String[] { arg }); + return compose(key, new Object[] { arg }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with two arguments. */ - public static String compose (String key, String arg1, String arg2) + public static String compose (String key, Object arg1, Object arg2) { - return compose(key, new String[] { arg1, arg2 }); + return compose(key, new Object[] { arg1, arg2 }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with three arguments. */ public static String compose ( - String key, String arg1, String arg2, String arg3) + String key, Object arg1, Object arg2, Object arg3) { - return compose(key, new String[] { arg1, arg2, arg3 }); + return compose(key, new Object[] { arg1, arg2, arg3 }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with a single argument that will be automatically tainted (see * {@link #taint}). */ - public static String tcompose (String key, String arg) + public static String tcompose (String key, Object arg) { - return compose(key, new String[] { taint(arg) }); + return compose(key, new Object[] { taint(arg) }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with two arguments that will be automatically tainted (see {@link * #taint}). */ - public static String tcompose (String key, String arg1, String arg2) + public static String tcompose (String key, Object arg1, Object arg2) { - return compose(key, new String[] { taint(arg1), taint(arg2) }); + return compose(key, new Object[] { taint(arg1), taint(arg2) }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with three arguments that will be automatically tainted (see {@link * #taint}). */ public static String tcompose ( - String key, String arg1, String arg2, String arg3) + String key, Object arg1, Object arg2, Object arg3) { - return compose(key, new String[] { + return compose(key, new Object[] { taint(arg1), taint(arg2), taint(arg3) }); } /** - * A convenience method for calling {@link #compose(String,String[])} + * A convenience method for calling {@link #compose(String,Object[])} * with an array of arguments that will be automatically tainted (see * {@link #taint}). */ - public static String tcompose (String key, String[] args) + public static String tcompose (String key, Object[] args) { return MessageUtil.tcompose(key, args); } diff --git a/src/java/com/threerings/whirled/spot/server/SpotProvider.java b/src/java/com/threerings/whirled/spot/server/SpotProvider.java index a2192f3a7..992087c20 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotProvider.java +++ b/src/java/com/threerings/whirled/spot/server/SpotProvider.java @@ -1,9 +1,10 @@ // -// $Id: SpotProvider.java,v 1.23 2004/02/25 14:50:28 mdb Exp $ +// $Id: SpotProvider.java,v 1.24 2004/03/06 11:29:19 mdb Exp $ package com.threerings.whirled.spot.server; import com.samskivert.util.StringUtil; +import com.threerings.util.Name; import com.threerings.presents.data.ClientObject; import com.threerings.presents.dobj.RootDObjectManager; @@ -253,7 +254,7 @@ public class SpotProvider * @param message the text of the chat message. */ public void sendClusterChatMessage ( - int sceneId, int speakerOid, String speaker, + int sceneId, int speakerOid, Name speaker, String bundle, String message, byte mode) { // look up the scene manager for the specified scene diff --git a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java index a82fa5046..b43a5bf83 100644 --- a/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java +++ b/src/java/com/threerings/whirled/spot/server/SpotSceneManager.java @@ -1,5 +1,5 @@ // -// $Id: SpotSceneManager.java,v 1.50 2004/02/25 14:50:28 mdb Exp $ +// $Id: SpotSceneManager.java,v 1.51 2004/03/06 11:29:19 mdb Exp $ package com.threerings.whirled.spot.server; @@ -7,6 +7,7 @@ import java.util.Iterator; import com.samskivert.util.HashIntMap; import com.samskivert.util.IntIntMap; +import com.threerings.util.Name; import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.Subscriber; @@ -368,7 +369,7 @@ public class SpotSceneManager extends SceneManager * request. */ protected void handleClusterSpeakRequest ( - int sourceOid, String source, String bundle, String message, byte mode) + int sourceOid, Name source, String bundle, String message, byte mode) { ClusterRecord clrec = getCluster(sourceOid); if (clrec == null) {