|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.jetrix.clients.TetrinetClient
public class TetrinetClient
Layer handling communication with a tetrinet or tetrifast client. Incomming messages are turned into a server understandable format and forwarded to the apropriate destination for processing (the player's channel or the main server thread)
| Field Summary | |
|---|---|
protected Date |
connectionTime
|
protected boolean |
disconnected
|
protected String |
encoding
|
protected InputStream |
in
|
protected long |
lastMessageTime
|
protected Logger |
log
|
protected OutputStream |
out
|
protected BlockingQueue<Message> |
queue
|
protected ServerConfig |
serverConfig
|
protected Socket |
socket
|
| Constructor Summary | |
|---|---|
TetrinetClient()
|
|
TetrinetClient(User user)
|
|
TetrinetClient(User user,
Socket socket)
|
|
| Method Summary | |
|---|---|
void |
disconnect()
Trigger the disconnection of this client. |
String |
getAgent()
Returns the name of the user agent (GTetrinet, aTwin, Blocktrix...) |
Channel |
getChannel()
Return the channel this client subscribed to. |
Date |
getConnectionTime()
Return the time of the connection to the server. |
String |
getEncoding()
Returns the character encoding to be used for the messages sent to the client. |
long |
getIdleTime()
Return the time in miliseconds of inactivity. |
InetAddress |
getInetAddress()
Return the Internet address of this client. |
Protocol |
getProtocol()
Return the protocol used by this client. |
Socket |
getSocket()
|
User |
getUser()
Return the user associated to this client. |
String |
getVersion()
Return the version of the user agent (1.13, 1.14, etc) |
protected boolean |
isAsynchronous()
Tells if the messages are sent asynchroneously to the client. |
Message |
receive()
Receive a message sent by the client. |
void |
run()
Main loop listening and parsing messages sent by the client. |
void |
send(Message message)
Send a message to the client. |
void |
setAgent(String agent)
|
void |
setChannel(Channel channel)
Set the channel. |
void |
setProtocol(Protocol protocol)
Set the protocol. |
void |
setSocket(Socket socket)
|
void |
setUser(User user)
|
void |
setVersion(String version)
|
boolean |
supportsAutoJoin()
Tell if the client can be affected automatically to a channel on connecting to the server. |
boolean |
supportsMultipleChannels()
Tell if the client supports multiple channels simultaneously. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Date connectionTime
protected long lastMessageTime
protected boolean disconnected
protected InputStream in
protected OutputStream out
protected Socket socket
protected String encoding
protected ServerConfig serverConfig
protected BlockingQueue<Message> queue
protected Logger log
| Constructor Detail |
|---|
public TetrinetClient()
public TetrinetClient(User user)
public TetrinetClient(User user,
Socket socket)
| Method Detail |
|---|
public Protocol getProtocol()
getProtocol in interface Clientpublic void setProtocol(Protocol protocol)
public void run()
run in interface Runnablepublic void send(Message message)
Client
send in interface Clientsend in interface Destinationmessage - the message to send
public Message receive()
throws IOException
Client
receive in interface ClientIOExceptionpublic void setSocket(Socket socket)
public Socket getSocket()
public InetAddress getInetAddress()
Client
getInetAddress in interface Clientpublic void setChannel(Channel channel)
Client
setChannel in interface Clientpublic Channel getChannel()
Client
getChannel in interface Clientpublic boolean supportsMultipleChannels()
Client
supportsMultipleChannels in interface Clientpublic boolean supportsAutoJoin()
Client
supportsAutoJoin in interface Clientpublic void setUser(User user)
public User getUser()
Client
getUser in interface Clientpublic void setVersion(String version)
public String getVersion()
Client
getVersion in interface Clientpublic String getAgent()
Client
getAgent in interface Clientpublic void setAgent(String agent)
public Date getConnectionTime()
Client
getConnectionTime in interface Clientpublic long getIdleTime()
Client
getIdleTime in interface Clientpublic String getEncoding()
Client
getEncoding in interface Clientpublic void disconnect()
Client
disconnect in interface Clientprotected boolean isAsynchronous()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||