|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.javagamesfactory.nioservers.StringBasedServer
org.javagamesfactory.nioservers.SimpleServerDemo
public class SimpleServerDemo
This is the class that runs automatically if you run the jar-file as an executable
Starts a simple server, and a simple client, and sends the server a hello-world style message every 5 seconds, while printing a summary of what is happening to std-out
| Field Summary |
|---|
| Fields inherited from class org.javagamesfactory.nioservers.StringBasedServer |
|---|
connectedChannels, defaultByteBufferSize, logger, messageLengths, myInfo, pendingOutgoingEncodedMessages, pendingOutgoingMessages, port, readBufferIsEmpty, readByteBuffers, readCharBuffers, selector, status, targetPort, verboseLogger, writeByteBuffers |
| Constructor Summary | |
|---|---|
SimpleServerDemo(int p)
Delegates directly to super-constructor with same signature |
|
| Method Summary | |
|---|---|
protected void |
keyCancelled(java.nio.channels.SelectionKey key)
Empty method body |
static void |
main(java.lang.String[] args)
Accepts one optional argument - the port to which the server should bind itself |
protected void |
postSelect(long millisecondsSinceLastStarted)
Empty method body |
protected void |
processStringMessage(java.lang.String message,
java.nio.channels.SelectionKey key)
Simply prints the message to std-out |
| Methods inherited from class org.javagamesfactory.nioservers.StringBasedServer |
|---|
addErrorToKey, addMessageToKey, debug, debugVerbose, error, error, getNumberOfConnectedChannels, getPort, getStatus, info, info, infoVerbose, peekOutgoingMessageQueueForKey, readIncomingMessageFromKey, run, start, stop |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleServerDemo(int p)
throws java.net.UnknownHostException
p -
java.net.UnknownHostException| Method Detail |
|---|
protected void keyCancelled(java.nio.channels.SelectionKey key)
keyCancelled in class StringBasedServerprotected void postSelect(long millisecondsSinceLastStarted)
postSelect in class StringBasedServermillisecondsSinceLastStarted - the number of milliseconds since this method was last
called; i.e. the time at which it was INVOKED, not the time at which it RETURNED;
this is perfect for maintaining fixed-rate game loops
protected void processStringMessage(java.lang.String message,
java.nio.channels.SelectionKey key)
throws java.nio.channels.ClosedChannelException
processStringMessage in class StringBasedServerjava.nio.channels.ClosedChannelException
public static void main(java.lang.String[] args)
throws java.lang.Throwable
args -
java.lang.Throwable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||