netP5
Class AbstractTcpServer

java.lang.Object
  extended by netP5.AbstractTcpServer
All Implemented Interfaces:
Runnable, TcpPacketListener
Direct Known Subclasses:
TcpServer

public abstract class AbstractTcpServer
extends Object
implements Runnable, TcpPacketListener


Field Summary
static int MODE_NEWLINE
           
static int MODE_READLINE
           
static int MODE_STREAM
           
static int MODE_TERMINATED
           
 
Constructor Summary
AbstractTcpServer(int thePort, int theMode)
           
AbstractTcpServer(TcpPacketListener theTcpPacketListener, int thePort, int theMode)
           
 
Method Summary
 void ban(String theIP)
          ban an IP address from the server.
 void dispose()
          kill the server.
 TcpClient getClient(int theIndex)
          get a client at a specific position the client list.
 TcpClient[] getClients()
          get a list of all connected clients.
abstract  void handleInput(TcpPacket thePacket, int thePort)
           
 void process(TcpPacket thePacket, int thePort)
           
 void remove(AbstractTcpClient theTcpClient)
          remove a TcpClient from the server's client list.
 void run()
           
 void send(byte[] theBytes)
          send a byte array to the connected client(s).
 void send(String theString)
          send a string to the connected client(s).
 int size()
          get the number of connected clients.
 ServerSocket socket()
          get the server socket object.
 void unBan(String theIP)
          remove the ban for an IP address.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface netP5.TcpPacketListener
status
 

Field Detail

MODE_READLINE

public static final int MODE_READLINE
See Also:
Constant Field Values

MODE_TERMINATED

public static final int MODE_TERMINATED
See Also:
Constant Field Values

MODE_NEWLINE

public static final int MODE_NEWLINE
See Also:
Constant Field Values

MODE_STREAM

public static final int MODE_STREAM
See Also:
Constant Field Values
Constructor Detail

AbstractTcpServer

public AbstractTcpServer(int thePort,
                         int theMode)
Parameters:
thePort - int
theMode - int

AbstractTcpServer

public AbstractTcpServer(TcpPacketListener theTcpPacketListener,
                         int thePort,
                         int theMode)
Parameters:
theTcpPacketListener - TcpPacketListener
thePort - int
theMode - int
Method Detail

ban

public void ban(String theIP)
ban an IP address from the server.

Parameters:
theIP -

unBan

public void unBan(String theIP)
remove the ban for an IP address.

Parameters:
theIP -

socket

public ServerSocket socket()
get the server socket object. more at java.net.ServerSocket

Returns:

run

public void run()
Specified by:
run in interface Runnable

send

public void send(String theString)
send a string to the connected client(s).

Parameters:
theString -

send

public void send(byte[] theBytes)
send a byte array to the connected client(s).

Parameters:
theBytes -

dispose

public void dispose()
kill the server.


size

public int size()
get the number of connected clients.

Returns:

getClients

public TcpClient[] getClients()
get a list of all connected clients. an array of type TcpClient[] will be returned.

Returns:

getClient

public TcpClient getClient(int theIndex)
get a client at a specific position the client list.

Parameters:
theIndex -
Returns:

process

public void process(TcpPacket thePacket,
                    int thePort)
Specified by:
process in interface TcpPacketListener
Parameters:
thePacket - TcpPacket
thePort - int

handleInput

public abstract void handleInput(TcpPacket thePacket,
                                 int thePort)
Parameters:
thePacket - TcpPacket
thePort - int

remove

public void remove(AbstractTcpClient theTcpClient)
remove a TcpClient from the server's client list.

Specified by:
remove in interface TcpPacketListener
Parameters:
theTcpClient - TCPClientAbstract


processing library oscP5 by Andreas Schlegel. (c) 2004-2012