Yay for rabbit holes. Revamped the table services to decouple them from places.

While I was in there, I extracted the communication between the client and the
TableManager into a new-style "embedded in the TableLobbyObject" service
instead of wonkily routing everything through the global ParlorService and the
ParlorProvider (which got merged into the ParlorManager as a part of this
rabbit holery). The GG build will break... I will fix it.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@255 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2007-03-21 21:38:31 +00:00
parent f61250f75b
commit b71007a909
24 changed files with 936 additions and 793 deletions
@@ -22,7 +22,6 @@
package com.threerings.parlor.data;
import com.threerings.parlor.client.ParlorService;
import com.threerings.parlor.data.TableConfig;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService;
@@ -75,41 +74,6 @@ public class ParlorMarshaller extends InvocationMarshaller
}
}
/**
* Marshalls results to implementations of {@link TableListener}.
*/
public static class TableMarshaller extends ListenerMarshaller
implements TableListener
{
/** The method id used to dispatch {@link #tableCreated}
* responses. */
public static final int TABLE_CREATED = 1;
// from interface TableMarshaller
public void tableCreated (int arg1)
{
_invId = null;
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, TABLE_CREATED,
new Object[] { Integer.valueOf(arg1) }));
}
@Override // from InvocationMarshaller
public void dispatchResponse (int methodId, Object[] args)
{
switch (methodId) {
case TABLE_CREATED:
((TableListener)listener).tableCreated(
((Integer)args[0]).intValue());
return;
default:
super.dispatchResponse(methodId, args);
return;
}
}
}
/** The method id used to dispatch {@link #cancel} requests. */
public static final int CANCEL = 1;
@@ -123,21 +87,8 @@ public class ParlorMarshaller extends InvocationMarshaller
});
}
/** The method id used to dispatch {@link #createTable} requests. */
public static final int CREATE_TABLE = 2;
// from interface ParlorService
public void createTable (Client arg1, int arg2, TableConfig arg3, GameConfig arg4, ParlorService.TableListener arg5)
{
ParlorMarshaller.TableMarshaller listener5 = new ParlorMarshaller.TableMarshaller();
listener5.listener = arg5;
sendRequest(arg1, CREATE_TABLE, new Object[] {
Integer.valueOf(arg2), arg3, arg4, listener5
});
}
/** The method id used to dispatch {@link #invite} requests. */
public static final int INVITE = 3;
public static final int INVITE = 2;
// from interface ParlorService
public void invite (Client arg1, Name arg2, GameConfig arg3, ParlorService.InviteListener arg4)
@@ -149,34 +100,8 @@ public class ParlorMarshaller extends InvocationMarshaller
});
}
/** The method id used to dispatch {@link #joinTable} requests. */
public static final int JOIN_TABLE = 4;
// from interface ParlorService
public void joinTable (Client arg1, int arg2, int arg3, int arg4, InvocationService.InvocationListener arg5)
{
ListenerMarshaller listener5 = new ListenerMarshaller();
listener5.listener = arg5;
sendRequest(arg1, JOIN_TABLE, new Object[] {
Integer.valueOf(arg2), Integer.valueOf(arg3), Integer.valueOf(arg4), listener5
});
}
/** The method id used to dispatch {@link #leaveTable} requests. */
public static final int LEAVE_TABLE = 5;
// from interface ParlorService
public void leaveTable (Client arg1, int arg2, int arg3, InvocationService.InvocationListener arg4)
{
ListenerMarshaller listener4 = new ListenerMarshaller();
listener4.listener = arg4;
sendRequest(arg1, LEAVE_TABLE, new Object[] {
Integer.valueOf(arg2), Integer.valueOf(arg3), listener4
});
}
/** The method id used to dispatch {@link #respond} requests. */
public static final int RESPOND = 6;
public static final int RESPOND = 3;
// from interface ParlorService
public void respond (Client arg1, int arg2, int arg3, Object arg4, InvocationService.InvocationListener arg5)
@@ -189,7 +114,7 @@ public class ParlorMarshaller extends InvocationMarshaller
}
/** The method id used to dispatch {@link #startSolitaire} requests. */
public static final int START_SOLITAIRE = 7;
public static final int START_SOLITAIRE = 4;
// from interface ParlorService
public void startSolitaire (Client arg1, GameConfig arg2, InvocationService.ConfirmListener arg3)
@@ -200,17 +125,4 @@ public class ParlorMarshaller extends InvocationMarshaller
arg2, listener3
});
}
/** The method id used to dispatch {@link #startTableNow} requests. */
public static final int START_TABLE_NOW = 8;
// from interface ParlorService
public void startTableNow (Client arg1, int arg2, int arg3, InvocationService.InvocationListener arg4)
{
ListenerMarshaller listener4 = new ListenerMarshaller();
listener4.listener = arg4;
sendRequest(arg1, START_TABLE_NOW, new Object[] {
Integer.valueOf(arg2), Integer.valueOf(arg3), listener4
});
}
}
@@ -53,4 +53,15 @@ public interface TableLobbyObject
* tables set (using the appropriate distributed object mechanisms).
*/
public void removeFromTables (Comparable key);
/**
* Returns a reference to the table service configured in this object.
*/
public TableMarshaller getTableService ();
/**
* Configures the table service that clients should use to communicate table requests back to
* the table manager handling these tables.
*/
public void setTableService (TableMarshaller service);
}
@@ -0,0 +1,93 @@
//
// $Id$
//
// Vilya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/vilya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.parlor.data;
import com.threerings.parlor.client.TableService;
import com.threerings.parlor.data.TableConfig;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent;
/**
* Provides the implementation of the {@link TableService} interface
* that marshalls the arguments and delivers the request to the provider
* 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.
*/
public class TableMarshaller extends InvocationMarshaller
implements TableService
{
/** The method id used to dispatch {@link #createTable} requests. */
public static final int CREATE_TABLE = 1;
// from interface TableService
public void createTable (Client arg1, TableConfig arg2, GameConfig arg3, InvocationService.ResultListener arg4)
{
InvocationMarshaller.ResultMarshaller listener4 = new InvocationMarshaller.ResultMarshaller();
listener4.listener = arg4;
sendRequest(arg1, CREATE_TABLE, new Object[] {
arg2, arg3, listener4
});
}
/** The method id used to dispatch {@link #joinTable} requests. */
public static final int JOIN_TABLE = 2;
// from interface TableService
public void joinTable (Client arg1, int arg2, int arg3, InvocationService.InvocationListener arg4)
{
ListenerMarshaller listener4 = new ListenerMarshaller();
listener4.listener = arg4;
sendRequest(arg1, JOIN_TABLE, new Object[] {
Integer.valueOf(arg2), Integer.valueOf(arg3), listener4
});
}
/** The method id used to dispatch {@link #leaveTable} requests. */
public static final int LEAVE_TABLE = 3;
// from interface TableService
public void leaveTable (Client arg1, int arg2, InvocationService.InvocationListener arg3)
{
ListenerMarshaller listener3 = new ListenerMarshaller();
listener3.listener = arg3;
sendRequest(arg1, LEAVE_TABLE, new Object[] {
Integer.valueOf(arg2), listener3
});
}
/** The method id used to dispatch {@link #startTableNow} requests. */
public static final int START_TABLE_NOW = 4;
// from interface TableService
public void startTableNow (Client arg1, int arg2, InvocationService.InvocationListener arg3)
{
ListenerMarshaller listener3 = new ListenerMarshaller();
listener3.listener = arg3;
sendRequest(arg1, START_TABLE_NOW, new Object[] {
Integer.valueOf(arg2), listener3
});
}
}