loginservicermiclient.java
来自「Java mulitplayer strategy game. Adaptati」· Java 代码 · 共 81 行
JAVA
81 行
/*
* LoginServiceRMIClient.java
*
* Created on 17 pa焏ziernik 2005, 20:25
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
package net.sf.jawp.gf.api.services.rmi;
import java.rmi.RemoteException;
import javax.security.auth.login.LoginException;
import net.sf.jawp.gf.api.services.LoginService;
import net.sf.jawp.gf.api.services.SessionService;
import net.sf.jawp.util.RMIWrapper;
import net.sf.jawp.util.RMIXWrapper;
/**
*
* @author jarek
* @param <FACTORY> factory for creating RMI game client
* @param <GAMESERVICE> native game service
*/
public final class LoginServiceRMIClient<GAMESERVICE , FACTORY extends GameServiceClientFactory<GAMESERVICE> > implements LoginService<GAMESERVICE>
{
private final LoginServiceRMI<GAMESERVICE> service;
private final FACTORY gameClientFactory;
/** Creates a new instance of LoginServiceRMIClient */
public LoginServiceRMIClient(final LoginServiceRMI<GAMESERVICE> srv, final FACTORY f)
{
this.service = srv;
this.gameClientFactory = f;
}
public String getServerSeed()
{
return new RMIWrapper<LoginServiceRMI<GAMESERVICE>, String>( this.service )
{
@Override
protected String perform(final LoginServiceRMI<GAMESERVICE> rmi) throws RemoteException
{
return rmi.getServerSeed();
}
}.call();
}
public SessionService<GAMESERVICE> login(final String clientString)
throws LoginException
{
try
{
final SessionServiceRMI< GAMESERVICE> srv =
new RMIXWrapper<LoginServiceRMI<GAMESERVICE>, SessionServiceRMI< GAMESERVICE> >( this.service )
{
@Override
protected SessionServiceRMI< GAMESERVICE> perform(final LoginServiceRMI<GAMESERVICE> rmi)
throws RemoteException, LoginException
{
return rmi.login(clientString);
}
}.call();
return new SessionServiceRMIClient< GAMESERVICE, FACTORY>(srv , this.gameClientFactory);
}
catch ( final LoginException le)
{
throw le;
}
catch (final Exception e)
{
throw new RuntimeException (e);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?