try {
SerialListener serial = new SerialListener();
TransListener transListener = new TransListener();
final PokersourceConnection conn = new PokersourceConnection(server);
conn.addListeners(serial, transListener);
conn.send(new Login(username, password));
serialObtained.await();
conn.removeListeners(serial, transListener);
return new PSServerContext(conn, serial.getSerial());
} catch (IOException e) {
throw new LoginException(e.getMessage());