|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmcast.MCastPacket
public class MCastPacket
An MCastPacket is a:
|-------------------------------------------------------------------| | pkt type | user payload | | (header) | | |-------------------------------------------------------------------|The pkt type is an int (4 bytes).
An MCastPacket object contains a DatagramPacket object (which is what is actually carried across the network). The MCastPacket's function is to provide a packet type: see the defined constants below. The DatagramPacket is used to manipulate addresses.
Field Summary | |
---|---|
protected byte[] |
buf
|
static int |
CLIENT_CLIENT_GOODBYE
Packet type Sent to all clients in the mcast group when one is done sending and wants to leave the group. |
static int |
CLIENT_MCAST
Packet type A normal client multicast msg, presumably carrying some data payload. |
static int |
CLIENT_SERVER_HELLO
Packet type part of the join protocol; the client tells lobby it's here, and waits to hear back before allowing the user thread to continue. |
static int |
HEADER_SIZE
|
static int |
MAX_PACKET_SIZE
|
static int |
MAX_PAYLOAD_SIZE
|
private java.net.DatagramPacket |
myDGPacket
|
static int |
SERVER_CLIENT_HELLO
Packet type Once server has received HELLO msgs from all the clients it is expecting, it replies to each with one of these. |
static int |
SOCKET_CLOSED
Packet type A pseudo-type used by socket implementations to indicate that this is the last packet that can be received, ever. |
Constructor Summary | |
---|---|
MCastPacket()
By default, create a packet with type suitable for client sending. |
|
MCastPacket(java.net.DatagramPacket dgPkt)
Constructor for incoming packets. |
|
MCastPacket(int type)
Constructor for outgoing packets. |
Method Summary | |
---|---|
java.net.InetSocketAddress |
getAddress()
Returns the address of the packet (useful when receiving a packet). |
(package private) byte[] |
getBuf()
Gets a reference to the lowest level (datagram packet) buffer. |
(package private) java.net.DatagramPacket |
getDGPacket()
Provides access to the contained DG packet, which is required to set or get packet addresses (or to directly manipulate packet lengths). |
byte[] |
getPayload()
Returns the payload - everything past the MCastPacket header. |
int |
getPayloadLength()
Returns the number of bytes in the packet past the MCastPacket header. |
int |
getType()
Extracts the packet type from the header and returns it. |
void |
setAddress(java.net.InetSocketAddress addr)
Sets the address of this packet (so useful when you're going to send the packet). |
void |
setPayload(byte[] payload)
Sets the payload, as seen from the perspective of an MCastPacket. |
protected void |
setPayloadLength(int len)
Sets the payload length (in the underlying DatagramPacket). |
void |
setType(int type)
Set the MCastPacket type. |
java.lang.String |
toString()
The obligatory toString. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int CLIENT_SERVER_HELLO
public static final int SERVER_CLIENT_HELLO
public static final int CLIENT_MCAST
public static final int CLIENT_CLIENT_GOODBYE
public static final int SOCKET_CLOSED
public static final int MAX_PACKET_SIZE
public static final int HEADER_SIZE
public static final int MAX_PAYLOAD_SIZE
protected byte[] buf
private java.net.DatagramPacket myDGPacket
Constructor Detail |
---|
public MCastPacket()
public MCastPacket(int type)
type
- one of the defined constant MCastPacket typespublic MCastPacket(java.net.DatagramPacket dgPkt)
dgPkt
- the received datagram packetMethod Detail |
---|
java.net.DatagramPacket getDGPacket()
public void setType(int type)
type
- The MCastPacket defined constant packet type.public int getType()
public void setPayload(byte[] payload)
protected void setPayloadLength(int len)
len
- payload length (excludes header)public byte[] getPayload()
public int getPayloadLength()
public void setAddress(java.net.InetSocketAddress addr)
public java.net.InetSocketAddress getAddress()
byte[] getBuf()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |