/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.cspoker.server.rmi.unremote.context;
import org.cspoker.common.api.chat.context.ChatContext;
import org.cspoker.common.api.chat.listener.RemoteChatListener;
import org.cspoker.common.api.lobby.context.ExternalLobbyContext;
import org.cspoker.common.api.lobby.listener.LobbyListener;
import org.cspoker.common.api.lobby.listener.RemoteLobbyListener;
import org.cspoker.common.api.shared.Trigger;
import org.cspoker.common.api.shared.context.ExternalServerContext;
import org.cspoker.common.api.shared.context.ForwardingServerContext;
import org.cspoker.common.api.shared.context.ServerContext;
import org.cspoker.common.elements.table.TableId;
import org.cspoker.server.rmi.unremote.listener.UnremoteChatListener;
import org.cspoker.server.rmi.unremote.listener.UnremoteLobbyListener;
public class UnremoteServerContext extends ForwardingServerContext implements ExternalServerContext {
private Trigger connectionLost;
public UnremoteServerContext(ServerContext serverContext) {
super(serverContext);
this.connectionLost = new Trigger(){
public void trigger() {
logout();
}
};
}
public UnremoteServerContext(Trigger connectionLost, ServerContext serverContext) {
super(serverContext);
this.connectionLost = connectionLost;
}
public ChatContext getServerChatContext(RemoteChatListener chatListener) {
return super.getServerChatContext(new UnremoteChatListener(connectionLost,chatListener));
}
public ChatContext getTableChatContext(RemoteChatListener chatListener,TableId tableId) {
return super.getTableChatContext(new UnremoteChatListener(connectionLost,chatListener),tableId);
}
public ExternalLobbyContext getLobbyContext(RemoteLobbyListener lobbyListener) {
return new UnremoteLobbyContext(connectionLost, super.getLobbyContext(new UnremoteLobbyListener(connectionLost, lobbyListener)));
}
@Override
public ExternalLobbyContext getLobbyContext(LobbyListener lobbyListener) {
return new UnremoteLobbyContext(connectionLost, super.getLobbyContext(lobbyListener));
}
}