|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.petterroea.starterkit.ServerSideConnection
public class ServerSideConnection
Used for a server side connection that can handle tonnes of connections. Use this if you want a game option to host a game, or if you are making a dedicated server
| Field Summary | |
|---|---|
private java.nio.charset.CharsetDecoder |
asciiDecoder
Char decoder |
(package private) java.util.LinkedList<ServerClient> |
clients
The clients connected to the server |
(package private) java.util.LinkedList<Packet> |
in
List of packets going in |
(package private) java.lang.Thread |
listener
The thread that listens to the network |
(package private) java.util.LinkedList<Packet> |
out
List of packets going out |
private java.nio.ByteBuffer |
readBuffer
The read buffer |
private java.nio.channels.Selector |
readSelector
Some random stuff. |
private boolean |
running
True if we are monitoring for commections and listening to packets |
private java.nio.channels.ServerSocketChannel |
sSChannel
The server socket channel |
static java.lang.Object |
sync
Synchronization object |
private java.nio.ByteBuffer |
writeBuffer
The writing-buffer |
| Constructor Summary | |
|---|---|
ServerSideConnection(int port)
Constructor for a serverside connection |
|
| Method Summary | |
|---|---|
private void |
acceptNewPeeps()
Used by the seperate thread to accept new connections |
private void |
channelWrite(java.nio.channels.SocketChannel channel,
java.nio.ByteBuffer writeBuffer)
Writes to a channel |
private void |
prepWriteBuffer(java.lang.String mesg)
Used for preparing writing to the client |
private void |
readIncomingMessages()
Reads incoming packets |
private void |
sendMessage(java.nio.channels.SocketChannel channel,
java.lang.String mesg)
Sends a message to the client. |
private void |
sendPackets()
Used by the seperate thread to send packets in the queue |
void |
start()
Runs the server network stuff |
void |
stop()
Stops the server network thingie. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.nio.ByteBuffer writeBuffer
private java.nio.charset.CharsetDecoder asciiDecoder
private java.nio.ByteBuffer readBuffer
java.lang.Thread listener
java.util.LinkedList<ServerClient> clients
private java.nio.channels.Selector readSelector
private boolean running
private java.nio.channels.ServerSocketChannel sSChannel
java.util.LinkedList<Packet> in
java.util.LinkedList<Packet> out
public static java.lang.Object sync
| Constructor Detail |
|---|
public ServerSideConnection(int port)
port - The port to bind to| Method Detail |
|---|
public void start()
private void sendPackets()
private void sendMessage(java.nio.channels.SocketChannel channel,
java.lang.String mesg)
channel - The channel from the clientmesg - The message to be sendtprivate void readIncomingMessages()
private void channelWrite(java.nio.channels.SocketChannel channel,
java.nio.ByteBuffer writeBuffer)
channel - The channelwriteBuffer - The bufferprivate void prepWriteBuffer(java.lang.String mesg)
mesg - private void acceptNewPeeps()
public void stop()
throws java.lang.InterruptedException,
java.io.IOException
java.lang.InterruptedException - If faied to join thread
java.io.IOException - If failed to close the socket
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||