Package net.sf.freecol.client.networking
Class UserServerAPI
- java.lang.Object
-
- net.sf.freecol.common.networking.ServerAPI
-
- net.sf.freecol.client.networking.UserServerAPI
-
public class UserServerAPI extends ServerAPI
Implementation of the ServerAPI for a player with a real connection to the server.
-
-
Field Summary
Fields Modifier and Type Field Description private Connection
connection
The connection used to communicate with the server.private java.lang.String
host
The last host connected to.private MessageHandler
messageHandler
The last message handler specified.private java.lang.String
name
The last name used to login with.private int
port
The last port connected to.
-
Constructor Summary
Constructors Constructor Description UserServerAPI()
Create the new user wrapper for the server API.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Connection
connect(java.lang.String name, java.lang.String host, int port)
Connects a client to host:port (or more).boolean
disconnect()
Disconnect from the server.Connection
getConnection()
Get the connection to communicate with the server.private java.lang.String
getHost()
Host accessor.private java.lang.String
getName()
Name accessor.private int
getPort()
Port accessor.private static Connection
newConnection(java.lang.String name, java.lang.String host, int port)
Create a new connection.Connection
reconnect()
Reconnect to the server.void
setMessageHandler(MessageHandler mh)
Sets the message handler for the connection.private void
updateConnection(Connection c)
A connection has been made, save it and its parameters.private void
updateParameters(java.lang.String name, java.lang.String host, int port)
Update the connection parameters so as to allow reconnection.-
Methods inherited from class net.sf.freecol.common.networking.ServerAPI
abandonColony, answerMonarch, askSkill, assignTeacher, assignTradeRoute, attack, buildColony, cashInTreasureTrain, changeState, changeWorkImprovementType, changeWorkType, chat, chooseFoundingFather, claimTile, clearSpeciality, continuePlaying, declareIndependence, declineMounds, deleteTradeRoute, deliverGiftToSettlement, demandTribute, diplomacy, disbandUnit, disembark, embark, emigrate, endTurn, enterRevengeMode, equipUnitForRole, firstContact, getHighScores, incite, indianDemand, isConnected, joinColony, learnSkill, loadGoods, login, logout, loot, missionary, move, moveTo, nationSummary, nativeGift, nativeTrade, newLandName, newNativeTradeSession, newRegionName, newTradeRoute, payArrears, payForBuilding, putOutsideColony, rearrangeColony, rename, requestLaunch, retire, scoutSettlement, scoutSpeakToChief, setAvailable, setBuildQueue, setColor, setCurrentStop, setDestination, setGoodsLevels, setNation, setNationType, setReady, spy, startSkipping, trainUnitInEurope, unloadGoods, updateGameOptions, updateMapGeneratorOptions, updateTradeRoute, work
-
-
-
-
Field Detail
-
connection
private Connection connection
The connection used to communicate with the server.
-
name
private java.lang.String name
The last name used to login with.
-
host
private java.lang.String host
The last host connected to.
-
port
private int port
The last port connected to.
-
messageHandler
private MessageHandler messageHandler
The last message handler specified.
-
-
Method Detail
-
getName
private java.lang.String getName()
Name accessor.- Returns:
- The connection name.
-
getHost
private java.lang.String getHost()
Host accessor.- Returns:
- The connection host.
-
getPort
private int getPort()
Port accessor.- Returns:
- The connection port.
-
updateParameters
private void updateParameters(java.lang.String name, java.lang.String host, int port)
Update the connection parameters so as to allow reconnection.- Parameters:
name
- The connection name.host
- The host connected to.port
- The port connected to.
-
updateConnection
private void updateConnection(Connection c)
A connection has been made, save it and its parameters.- Parameters:
c
- The newConnection
.
-
newConnection
private static Connection newConnection(java.lang.String name, java.lang.String host, int port) throws java.io.IOException
Create a new connection.- Parameters:
name
- The name to associate with the connection.host
- The name of the host to connect to.port
- The port to connect to.- Returns:
- The new
Connection
. - Throws:
java.io.IOException
- on failure to connect.
-
connect
public Connection connect(java.lang.String name, java.lang.String host, int port) throws java.io.IOException
Connects a client to host:port (or more).
-
disconnect
public boolean disconnect()
Disconnect from the server.- Specified by:
disconnect
in classServerAPI
- Returns:
- True if disconnected.
-
reconnect
public Connection reconnect() throws java.io.IOException
Reconnect to the server.
-
getConnection
public Connection getConnection()
Get the connection to communicate with the server.- Specified by:
getConnection
in classServerAPI
- Returns:
- The
Connection
to the server.
-
setMessageHandler
public void setMessageHandler(MessageHandler mh)
Sets the message handler for the connection.- Overrides:
setMessageHandler
in classServerAPI
- Parameters:
mh
- The newMessageHandler
.
-
-