game.net
Interface Server_network_interface

All Known Implementing Classes:
Server_network_layer

public interface Server_network_interface


Field Summary
static int EAST
          A constant identifying one controller.
static int WEST
          A constant identifying one controller.
 
Method Summary
 int get_line(int mask, java.lang.StringBuffer str_buf)
          Attempt to read one line from either client.
 void send_line(java.lang.String line, int which)
          Send one line to a client.
 

Field Detail

WEST

static final int WEST
A constant identifying one controller. EAST and WEST are uequal to each other and are both powers of 2. Note that the name WEST is not meant to convey that the controller controls the team on the "west" side of the field.

See Also:
Constant Field Values

EAST

static final int EAST
A constant identifying one controller. EAST and WEST are uequal to each other and are both powers of 2. Note that the name EAST is not meant to convey that the controller controls the team on the "west" side of the field.

See Also:
Constant Field Values
Method Detail

send_line

void send_line(java.lang.String line,
               int which)
               throws java.io.IOException
Send one line to a client.

Parameters:
line - this should end in a newline.
which - this should be server_network_layer.WEST or server_network_layer.EAST
Throws:
java.io.IOException - if the line can not be sent.

get_line

int get_line(int mask,
             java.lang.StringBuffer str_buf)
             throws java.io.IOException
Attempt to read one line from either client. Returns a line when a newline is read, or when its internal buffer is full. The internal buffer holds at least 1001 bytes.

The bytes read are converted to a string according to ASCII encoding

Byte value 10 is used to mark the end of lines.

Parameters:
mask - indicates where the line should come from. It may be, WEST, EAST, or WEST|EAST to indicate either is ok.
str_buf - a string buffer onto which the line will be appended if a line is read. Typically you would pass a new string buffer.
Returns:
server_network_layer.WEST if the line was gotten from the west client, server_network_layer.EAST if a line was gotten from the east client, and 0 if no line was read.
Throws:
java.io.IOException - if trouble reading the line.