megamek.common.net
Class ObjectStreamConnection
java.lang.Object
megamek.common.net.AbstractConnection
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.
| 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 |
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 -
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 sendzipped - should the data be compressed
- Throws:
java.lang.Exception