frams_client_3d
Class Communication

java.lang.Object
  extended byframs_client_3d.Communication

public class Communication
extends java.lang.Object

Communication class.

Author:
MoMaT

Field Summary
private  java.io.BufferedReader in
           
private  java.util.ArrayList log
           
private  java.io.PrintWriter out
           
private  java.net.Socket socket
           
 
Constructor Summary
Communication()
           
 
Method Summary
 void connect(java.lang.String ip, int port)
          Connect to a server.
 void disconnect()
          Close connection.
 java.util.ArrayList getLog()
          Log getter.
 java.util.ArrayList readMessage()
          Read a server response.
 void sendMessage(java.lang.String message)
          Send request to a server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socket

private java.net.Socket socket

out

private java.io.PrintWriter out

in

private java.io.BufferedReader in

log

private java.util.ArrayList log
Constructor Detail

Communication

public Communication()
Method Detail

connect

public void connect(java.lang.String ip,
                    int port)
             throws java.io.IOException
Connect to a server.

Parameters:
ip -
port -
Throws:
java.io.IOException - Thrown on I/O error.

disconnect

public void disconnect()
                throws java.io.IOException
Close connection.

Throws:
java.io.IOException - Thrown on socket close error.

readMessage

public java.util.ArrayList readMessage()
                                throws java.io.IOException,
                                       java.lang.InterruptedException,
                                       CommunicationErrorException
Read a server response.

Returns:
server answer
Throws:
java.io.IOException - Thrown on read error.
java.lang.InterruptedException - Thrown on thread sleep interruption.
CommunicationErrorException - Thrown on protocol error.

sendMessage

public void sendMessage(java.lang.String message)
Send request to a server.

Parameters:
message -

getLog

public java.util.ArrayList getLog()
Log getter.

Returns:
log array