megamek.common.net
Class ObjectStreamConnection

java.lang.Object
  extended by megamek.common.net.AbstractConnection
      extended by megamek.common.net.ObjectStreamConnection
All Implemented Interfaces:
IConnection

 class ObjectStreamConnection
extends AbstractConnection

Implementation of the Connection that uses the ObjectInputStream and ObjectOutputStream to send/receive data.


Nested Class Summary
 
Nested classes/interfaces inherited from class megamek.common.net.AbstractConnection
AbstractConnection.INetworkPacket, AbstractConnection.SendQueue
 
Field Summary
 
Fields inherited from class megamek.common.net.AbstractConnection
bytesSent, marshaller, marshallingType, zipData
 
Constructor Summary
ObjectStreamConnection(java.net.Socket socket, int id)
          Creates new server connection
ObjectStreamConnection(java.lang.String host, int port, int id)
          Creates new Client connection
 
Method Summary
protected  AbstractConnection.INetworkPacket readNetworkPacket()
          Reads a complete NetworkPacket must not block, must return null instead
protected  void sendNetworkPacket(byte[] data, boolean zipped)
          Sends the data must not block for too long
 
Methods inherited from class megamek.common.net.AbstractConnection
addConnectionListener, bytesReceived, bytesSent, close, doFlush, flush, getConnectionTypeAbbrevation, getId, getInetAddress, getInputStream, getMarshallingType, getOutputStream, hasPending, isCompressed, isServer, open, processConnectionEvent, processPacket, processPacket, removeConnectionListener, reportLastCommands, reportLastCommands, reportReceiveException, reportReceiveException, reportSendException, send, sendNow, setCompression, setId, setMarshallingType, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectStreamConnection

public ObjectStreamConnection(java.net.Socket socket,
                              int id)
Creates new server connection

Parameters:
socket -
id -

ObjectStreamConnection

public ObjectStreamConnection(java.lang.String host,
                              int port,
                              int id)
Creates new Client connection

Parameters:
host -
port -
id -
Method Detail

readNetworkPacket

protected AbstractConnection.INetworkPacket readNetworkPacket()
                                                       throws java.lang.Exception
Description copied from class: AbstractConnection
Reads a complete NetworkPacket must not block, must return null instead

Specified by:
readNetworkPacket in class AbstractConnection
Returns:
the NetworkPacket that was sent.
Throws:
java.lang.Exception

sendNetworkPacket

protected void sendNetworkPacket(byte[] data,
                                 boolean zipped)
                          throws java.lang.Exception
Description copied from class: AbstractConnection
Sends the data must not block for too long

Specified by:
sendNetworkPacket in class AbstractConnection
Parameters:
data - data to send
zipped - should the data be compressed
Throws:
java.lang.Exception