I'm putting together a framework for some games via webservices, which for various reasons need to run without an application container.
At this point, all I'm after is that each player will authenticate, and hit the login service. The login service does not return until all players have logged in, so the players know that once their call is complete they can begin playing.
The issue I'm having is that this works fine without the authentication, but as soon as I enable the authentication, the first player authenticates and connects correctly, but the second player cannot connect as long as the first player is waiting for the login service to return.
The services look as follows:
public void login()
{
Game game = Game.getInstance();
while (game.getStatus() != Status.RUNNING)
{
try
{
Thread.sleep(10);
}
catch (InterruptedException e)
{
// swallow it, doesn't matter
}
}
}
The clients look like (stripped down to the connect logic):
public void clientLogin()
{
Authenticator.setDefault(new Authenticator()
{
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(getUsername(), getPassword());
}
});
QName qName = new QName("http://namespace/", "ChallengeService");
URL url = new URL(endPoint);
ChallengeService wsClient = new ChallengeService(url, qName);
System.out.println("Got Client");
wsPort = wsClient.getChallengePort();
wsPort.login();
}
The server is started with:
public void startServer()
{
server.start();
endpoint = Endpoint.create(new ChallengeService());
server = HttpServer.create(new InetSocketAddress(7070), 5);
context = server.createContext("/Challenge/ChallengeService");
context.setAuthenticator(new StandaloneAuthenticator("Challenge")); // disabling this works
endpoint.publish(context);
}
Any ideas?