udpSessionRegistry)
- {
- this.udpSessionRegistry = udpSessionRegistry;
- }
-
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/AMF3Protocol.java b/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/AMF3Protocol.java
deleted file mode 100644
index f0b36689..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/AMF3Protocol.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.menacheri.jetserver.protocols.impl;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldPrepender;
-import org.menacheri.jetserver.app.PlayerSession;
-import org.menacheri.jetserver.event.Event;
-import org.menacheri.jetserver.handlers.netty.AMF3ToEventSourceDecoder;
-import org.menacheri.jetserver.handlers.netty.DefaultToServerHandler;
-import org.menacheri.jetserver.handlers.netty.EventDecoder;
-import org.menacheri.jetserver.handlers.netty.EventEncoder;
-import org.menacheri.jetserver.handlers.netty.EventSourceToAMF3Encoder;
-import org.menacheri.jetserver.protocols.AbstractNettyProtocol;
-import org.menacheri.jetserver.util.NettyUtils;
-
-
-/**
- * This protocol defines AMF3 as a byte array being sent over the wire. Used by
- * flash clients that use Socket class. This class applies the flash AMF3
- * protocol to the {@link PlayerSession}'s pipeline. The major handlers
- * involved are {@link AMF3ToEventSourceDecoder} and
- * {@link EventSourceToAMF3Encoder}.
- *
- * @author Abraham Menacherry
- *
- *
- */
-public class AMF3Protocol extends AbstractNettyProtocol
-{
- /**
- * After the frame decoder retrieves the bytes from the incoming stream,
- * this decoder will convert it to an {@link Event} with the opcode set as
- * the first byte read from the buffer. And the source object of the event
- * created will have the rest of the {@link ChannelBuffer}.
- */
- private EventDecoder eventDecoder;
-
- /**
- * This decoder will do the actual serialization to java object. Any game
- * handlers need to be added after this in the pipeline so that they can
- * operate on the java object.
- */
- private AMF3ToEventSourceDecoder amf3ToEventSourceDecoder;
-
- /**
- * Once the game handler is done with its operations, it writes back the
- * java object to the client. When writing back to flash client, it needs to
- * use this encoder to encode it to AMF3 format.
- */
- private EventSourceToAMF3Encoder eventSourceToAMF3Encoder;
-
- /**
- * This encoder will take the event parsed by the java object to AMF3
- * encoder and create a single wrapped {@link ChannelBuffer} with the opcode
- * as header and amf3 bytes as body.
- */
- private EventEncoder eventEncoder;
-
- /**
- * Utility handler provided by netty to add the length of the outgoing
- * message to the message as a header.
- */
- private LengthFieldPrepender lengthFieldPrepender;
-
- public AMF3Protocol()
- {
- super("AMF3");
- }
-
- @Override
- public void applyProtocol(PlayerSession playerSession)
- {
- ChannelPipeline pipeline = NettyUtils
- .getPipeLineOfConnection(playerSession);
-
- // Upstream handlers or encoders (i.e towards server) are added to
- // pipeline now.
- pipeline.addLast("lengthDecoder", createLengthBasedFrameDecoder());
- pipeline.addLast("eventDecoder",eventDecoder);
- pipeline.addLast("amf3ToEventSourceDecoder", amf3ToEventSourceDecoder);
- pipeline.addLast("eventHandler", new DefaultToServerHandler(
- playerSession));
-
- // Downstream handlers (i.e towards client) are added to pipeline now.
- // NOTE the last encoder in the pipeline is the first encoder to be called.
- pipeline.addLast("lengthFieldPrepender", lengthFieldPrepender);
- pipeline.addLast("eventEncoder",eventEncoder);
- pipeline.addLast("eventSourceToAMF3Encoder", eventSourceToAMF3Encoder);
- }
-
- public EventSourceToAMF3Encoder getEventSourceToAMF3Encoder()
- {
- return eventSourceToAMF3Encoder;
- }
-
- public LengthFieldPrepender getLengthFieldPrepender()
- {
- return lengthFieldPrepender;
- }
-
- public EventDecoder getEventDecoder()
- {
- return eventDecoder;
- }
-
- public EventEncoder getEventEncoder()
- {
- return eventEncoder;
- }
-
- public AMF3ToEventSourceDecoder getAmf3ToEventSourceDecoder()
- {
- return amf3ToEventSourceDecoder;
- }
-
- public void setEventDecoder(EventDecoder eventDecoder)
- {
- this.eventDecoder = eventDecoder;
- }
-
- public void setEventSourceToAMF3Encoder(
- EventSourceToAMF3Encoder eventToAMF3Encoder)
- {
- this.eventSourceToAMF3Encoder = eventToAMF3Encoder;
- }
-
- public void setEventEncoder(EventEncoder eventEncoder)
- {
- this.eventEncoder = eventEncoder;
- }
-
- public void setLengthFieldPrepender(LengthFieldPrepender lengthFieldPrepender)
- {
- this.lengthFieldPrepender = lengthFieldPrepender;
- }
-
- public void setAmf3ToEventSourceDecoder(
- AMF3ToEventSourceDecoder amf3ToEventSourceDecoder)
- {
- this.amf3ToEventSourceDecoder = amf3ToEventSourceDecoder;
- }
-
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/SimpleByteArrayProtocol.java b/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/SimpleByteArrayProtocol.java
deleted file mode 100644
index e43e47b0..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/SimpleByteArrayProtocol.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.menacheri.jetserver.protocols.impl;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldPrepender;
-import org.menacheri.jetserver.app.PlayerSession;
-import org.menacheri.jetserver.handlers.netty.ByteArrayDecoder;
-import org.menacheri.jetserver.handlers.netty.ByteArrayToChannelBufferEncoder;
-import org.menacheri.jetserver.protocols.AbstractNettyProtocol;
-import org.menacheri.jetserver.util.NettyUtils;
-import org.springframework.beans.factory.annotation.Required;
-
-
-/**
- * A protocol that can be used for fast paced games where operations and other
- * values can be sent as bytes which then get processed and converted to actual
- * java method operations. Messages with pay load like [OPCODE][PAYLOAD] will
- * find this protocol the most useful.
- *
- * @author Abraham Menacherry
- *
- */
-public class SimpleByteArrayProtocol extends AbstractNettyProtocol
-{
- /**
- * Used to retrieve the rest of the bytes after the length field is
- * stripped.
- */
- private ByteArrayDecoder byteArrayDecoder;
- /**
- * Converts a byte array to a {@link ChannelBuffer} while sending to the client.
- */
- private ByteArrayToChannelBufferEncoder byteArrayToChannelBufferEncoder;
- /**
- * Utility handler provided by netty to add the length of the outgoing
- * message to the message as a header.
- */
- private LengthFieldPrepender lengthFieldPrepender;
-
- public SimpleByteArrayProtocol()
- {
- super("SIMPLE_BYTE_ARRAY_PROTOCOL");
- }
-
- public SimpleByteArrayProtocol(ByteArrayDecoder byteArrayDecoder,
- LengthFieldPrepender lengthFieldPrepender)
- {
- super("SIMPLE_BYTE_ARRAY_PROTOCOL");
- this.byteArrayDecoder = byteArrayDecoder;
- this.lengthFieldPrepender = lengthFieldPrepender;
- }
-
- @Override
- public void applyProtocol(PlayerSession playerSession)
- {
- ChannelPipeline pipeline = NettyUtils
- .getPipeLineOfConnection(playerSession);
- // Upstream handlers or encoders (i.e towards server) are added to
- // pipeline now.
- pipeline.addLast("lengthDecoder", createLengthBasedFrameDecoder());
- pipeline.addLast("byteArrayDecoder", byteArrayDecoder);
-
- // Downstream handlers - Filter for data which flows from server to
- // client. Note that the last handler added is actually the first
- // handler for outgoing data.
- pipeline.addLast("byteArrayToChannelBufferEncoder", byteArrayToChannelBufferEncoder);
- pipeline.addLast("lengthFieldPrepender", lengthFieldPrepender);
- }
-
- public ByteArrayDecoder getByteArrayDecoder()
- {
- return byteArrayDecoder;
- }
-
- @Required
- public void setByteArrayDecoder(ByteArrayDecoder byteArrayDecoder)
- {
- this.byteArrayDecoder = byteArrayDecoder;
- }
-
- public LengthFieldPrepender getLengthFieldPrepender()
- {
- return lengthFieldPrepender;
- }
-
- @Required
- public void setLengthFieldPrepender(LengthFieldPrepender lengthFieldPrepender)
- {
- this.lengthFieldPrepender = lengthFieldPrepender;
- }
-
- public ByteArrayToChannelBufferEncoder getByteArrayToChannelBufferEncoder()
- {
- return byteArrayToChannelBufferEncoder;
- }
-
- @Required
- public void setByteArrayToChannelBufferEncoder(
- ByteArrayToChannelBufferEncoder byteArrayToChannelBufferEncoder)
- {
- this.byteArrayToChannelBufferEncoder = byteArrayToChannelBufferEncoder;
- }
-
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/SimpleSgsProtocolConstants.java b/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/SimpleSgsProtocolConstants.java
deleted file mode 100644
index ecec7177..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/protocols/impl/SimpleSgsProtocolConstants.java
+++ /dev/null
@@ -1,468 +0,0 @@
-package org.menacheri.jetserver.protocols.impl;
-
-
-/**
- * SGS Protocol constants.
- *
- * A protocol message is constructed as follows:
- *
- * - (unsigned short) payload length, not including this field
- *
- (byte) operation code
- *
- optional content, depending on the operation code.
- *
- *
- * A {@code ByteArray} is encoded in a context dependent fashion. If the
- * ByteArray is the only content, or if the ByteArray is the last piece of
- * content (that is, if the length of the ByteArray can be determined by the
- * payload length and the length of what has come before), the ByteArray is
- * encoded as
- *
- * - (byte[]) the bytes in the array
- *
- * If there is other content that follows the ByteArray, then the ByteArray is
- * encoded as
- *
- * - (unsigned short) number of bytes in the array
- *
- (byte[]) content
- *
- *
- * A {@code String} is encoded as follows:
- *
- * - (unsigned short) number of bytes of modified UTF-8 encoded String
- *
- (byte[]) String encoded in modified UTF-8 as described in
- * {@link java.io.DataInput}
- *
- * Note that these encodings only apply to those data items that are specified
- * explicitly in the protocol. Application data, passed as a ByteArray, may
- * contain any information, but will need to be parsed (and, if necessary,
- * converted to and from a network representation) by the application or client.
- *
- * The total length of a message must not be greater than 65535 bytes; given the
- * header information this means that the payload of a message cannot be greater
- * than 65532 bytes. If a message larger than this must be sent, it is the
- * responsibility of the sender to break the message into pieces and of the
- * receiver to re-assemble those pieces.
- *
- * Behavior not specified in this document is left as an implementation
- * decision for the particular client and server. Information on the
- * implementation characteristics of the RedDwarf server can be found
- * in the overview for the
- * implementation.
- */
-public class SimpleSgsProtocolConstants{
-
- /**
- * This class should not be instantiated.
- */
- protected SimpleSgsProtocolConstants() {
- }
-
- /**
- * The maximum length of a protocol message:
- * {@value #MAX_MESSAGE_LENGTH} bytes.
- */
- public static final int MAX_MESSAGE_LENGTH = 65535;
-
- /**
- * The maximum payload length:
- * {@value #MAX_PAYLOAD_LENGTH} bytes.
- */
- public static final int MAX_PAYLOAD_LENGTH = 65532;
-
- /** The version number, currently {@code 0x05}. */
- public static final byte VERSION = 0x05;
-
- /**
- * Login request from a client to a server. This message should only be sent
- * to a server; if received by a client it should be ignored.
- * Opcode: {@code 0x10}
- * Payload:
- *
- * - (byte) protocol version
- *
- (String) name
- *
- (String) password
- *
- * The {@code protocol version} will be checked by the server to insure that
- * the client and server are using the same protocol or versions of the
- * protocol that are compatible. If the server determines that the protocol
- * version used by the sender and the protocol version or versions required
- * by the server are not compatible, the server will disconnect the client.
- * In cases where the protocols being used are not compatible, no other
- * communication between the client and the server is guaranteed to be
- * understood.
- *
- * The {@code name} and {@code password} strings are passed to the server's
- * authentication mechanism. After the server processes the login request,
- * the server sends one of the following acknowledgments to the client:
- *
- * - {@link #LOGIN_SUCCESS}, if user authentication succeeds and
- * invoking the {@code loggedIn}' method on the application's
- * {@code AppListener} with the user's {@code ClientSession} returns a
- * non-null, serializable {@code ClientSessionListener};
- *
- {@link #LOGIN_REDIRECT}, if user authentication succeeds, but the
- * server requests that the client redirect the login request to another
- * node; or
- *
- {@link #LOGIN_FAILURE}, if user authentication fails, or if the
- * user is already logged in and the server is configured to reject new
- * logins for the same user, or if invoking the {@code loggedIn} method on
- * the application's {@code AppListener} with the user's
- * {@code ClientSession} returns a null, or non-serializable
- * {@code ClientSessionListener} or the method does not complete
- * successfully.
- *
- *
- * If a client is currently logged in, the result of receiving a
- * LOGIN_REQUEST is not defined by the protocol, but is an
- * implementation-dependent detail of the server.
- */
- public static final byte LOGIN_REQUEST = 0x10;
-
- /**
- * Login success. Server response to a client's {@link #LOGIN_REQUEST}.
- *
- * Opcode: {@code 0x11}
- * Payload:
- *
- * - (ByteArray) reconnectionKey
- *
- * The {@code reconnectionKey} is an opaque reference that can be held by
- * the client for use in case the client is disconnected and wishes to
- * reconnect to the server with the same identity using a
- * {@link #RECONNECT_REQUEST}.
- */
- public static final byte LOGIN_SUCCESS = 0x11;
-
- /**
- * Login failure. Server response to a client's {@link #LOGIN_REQUEST}.
- *
- * Opcode: {@code 0x12}
- * Payload:
- *
- * This message indicates that the server rejects the {@link #LOGIN_REQUEST}
- * for some reason, for example
- *
- * - user authentication failure,
- *
- failure during application processing of the client session, or
- *
- a user with the same identity is already logged in, and the server
- * is configured to reject new logins for clients who are currently logged
- * in
- *
- *
- */
- public static final byte LOGIN_FAILURE = 0x12;
-
- /**
- * Login redirect. Server response to a client's {@link #LOGIN_REQUEST}.
- *
- * Opcode: {@code 0x13}
- * Payload:
- *
- * - (String) hostname
- *
- (int) port
- *
- * This message indicates a redirection from the node to which the
- * {@link #LOGIN_REQUEST} was sent to another node. The client receiving
- * this request should shut down the connection to the original node and
- * establish a connection to the node indicated by the {@code hostname} and
- * {@code port} in the payload. The client should then attempt to log in to
- * the node to which it has been redirected by sending a
- * {@link #LOGIN_REQUEST} to that node.
- */
- public static final byte LOGIN_REDIRECT = 0x13;
-
- /**
- * Suspend messages notification. Server to client notification.
- *
- * Opcode: {@code 0x14}
- * Payload: (none)
- *
- * This message notifies a client to suspend sending messages to the
- * server until it receives further instruction (such as {@link
- * #RELOCATE_NOTIFICATION} or {@link #RESUME_MESSAGES}). The client
- * should send the acknowledgment {@link #SUSPEND_MESSAGES_COMPLETE} to
- * the server when it has suspended sending messages. After the server
- * sends a {@code SUSPEND_MESSAGES} notification to the client, the
- * server may decide to drop messages from the client if it does not
- * receive the {@link #SUSPEND_MESSAGES_COMPLETE} acknowledgment in a
- * timely fashion.
- *
- * This opcode was introduced in protocol version {@code 0x05}.
- */
- public static final byte SUSPEND_MESSAGES = 0x14;
-
- /**
- * Acknowledgment of {@link #SUSPEND_MESSAGES} notification. Client to
- * server notification.
- *
- * Opcode: {@code 0x15}
- * Payload: (none)
- *
- * This message notifies the server that the client has received the
- * {@link #SUSPEND_MESSAGES} notification. Any messages received by the
- * server after this notification will be dropped, unless the server
- * has instructed the client to either resume messages or relocate its
- * client session to another node.
- *
- * This opcode was introduced in protocol version {@code 0x05}.
- */
- public static final byte SUSPEND_MESSAGES_COMPLETE = 0x15;
-
- /**
- * Resume messages notification. Server to client notification.
- *
- * Opcode: {@code 0x16}
- * Payload: (none)
- *
- * This message notifies the client that it can resume sending messages
- * to the server.
- *
- * This opcode was introduced in protocol version {@code 0x05}.
- */
- public static final byte RESUME_MESSAGES = 0x16;
-
- /**
- * Relocate session notification. Server to client notification.
- *
- * Opcode: {@code 0x17}
- * Payload:
- *
- * - (String) hostname
- *
- (int) port
- *
- (ByteArray) relocationKey
- *
- *
- * This message notifies a client to relocate its session on the
- * current node to a new node. The client receiving this request should
- * shut down the connection to the original node and establish a
- * connection to the node indicated by the {@code hostname} and {@code
- * port} in the payload. The client should then attempt to reestablish
- * the client session with the server (without logging in) using the
- * {@code relocationKey} specified in the payload.
- *
- * This opcode was introduced in protocol version {@code 0x05}.
- */
- public static final byte RELOCATE_NOTIFICATION = 0x17;
-
- /**
- * Relocation request. Client requesting relocation to a server.
- * Opcode: {@code 0x18}
- * Payload:
- *
- * - (byte) protocol version
- *
- (ByteArray) relocationKey
- *
- *
- * This message requests that the client's existing client session be
- * relocated to (and re-established with) the server. The {@code
- * relocationKey} must match the one that the client received in the
- * previous {@link #RELOCATE_NOTIFICATION} message. If relocation is
- * successful, the server acknowledges the request with a {@link
- * #RELOCATE_SUCCESS} message containing a {@code reconnectionKey} for
- * reconnecting to the server. If relocation is not successful, a
- * {@link #RELOCATE_FAILURE} message is sent to the client. If the
- * client receives a {@code RELOCATE_FAILURE} message, the client
- * should disconnect from the server.
- *
- * This opcode was introduced in protocol version {@code 0x05}.
- */
- public static final byte RELOCATE_REQUEST = 0x18;
-
- /**
- * Relocation success. Server response to a client's {@link
- * #RELOCATE_REQUEST}.
- *
- * Opcode: {@code 0x19}
- * Payload:
- *
- * - (ByteArray) reconnectionKey
- *
- * The {@code reconnectionKey} is an opaque reference that can be held by
- * the client for use in case the client is disconnected and wishes to
- * reconnect to the server with the same identity using a
- * {@link #RECONNECT_REQUEST}.
- *
- * This opcode was introduced in protocol version {@code 0x05}.
- */
- public static final byte RELOCATE_SUCCESS = 0x19;
-
- /**
- * Relocate failure. Server response to a client's {@link
- * #RELOCATE_REQUEST}.
- *
- * Opcode: {@code 0x1a}
- * Payload:
- *
- * This message indicates that the server rejects the {@link
- * #RELOCATE_REQUEST} for some reason, for example
- *
- * - session not relocating to the server
- *
- relocation key mismatch
- *
- a user with the same identity is already logged in
- *
- *
- * This opcode was introduced in protocol version {@code 0x05}.
- */
- public static final byte RELOCATE_FAILURE = 0x1a;
-
- /**
- * Reconnection request. Client requesting reconnect to a server.
- * Opcode: {@code 0x20}
- * Payload:
- *
- * - (byte) protocol version
- *
- (ByteArray) reconnectionKey
- *
- * This message requests that the client be reconnected to an existing
- * client session with the server. The {@code reconnectionKey} must match
- * the one that the client received in the previous {@link #LOGIN_SUCCESS}
- * or {@link #RECONNECT_SUCCESS} message (if reconnection was performed
- * subsequent to login). If reconnection is successful, the server
- * acknowledges the request with a {@link #RECONNECT_SUCCESS} message
- * containing a new {@code reconnectionKey}. If reconnection is not
- * successful, a {@link #RECONNECT_FAILURE} message is sent to the client.
- * If the client receives a {@code RECONNECT_FAILURE} message, the client
- * should disconnect from the server.
- */
- public static final byte RECONNECT_REQUEST = 0x20;
-
- /**
- * Reconnect success. Server response to a client's
- * {@link #RECONNECT_REQUEST}.
- * Opcode: {@code 0x21}
- * Payload:
- *
- * - (ByteArray) reconnectionKey
- *
- * Indicates that a {@link #RECONNECT_REQUEST} has been successful. The
- * message will include a {@code reconnectionKey} that can be used in a
- * subsequent reconnect requests from the client. Reciept of this message
- * indicates that the client session has been re-established.
- */
- public static final byte RECONNECT_SUCCESS = 0x21;
-
- /**
- * Reconnect failure. Server response to a client's
- * {@link #RECONNECT_REQUEST}.
- *
- * Opcode: {@code 0x22}
- *
- * Payload:
- *
- * This response indicates that a reconnect request could not be honored by
- * the server. This could be because of an invalid reconnect key, or
- * because too much time has elapsed between the session disconnection and
- * the reconnect request (which, in turn, may cause the server to
- * discard the session state). The string returned details the reason for
- * the denial of reconnection.
- */
- public static final byte RECONNECT_FAILURE = 0x22;
-
- /**
- * Session message. May be sent by the client or the server. Maximum length
- * is {@value #MAX_PAYLOAD_LENGTH} bytes. Larger messages require
- * fragmentation and reassembly above this protocol layer.
- *
- * Opcode: {@code 0x30}
- *
- * Payload:
- *
- * - (ByteArray) message
- *
- * This message allows information to be sent between the client and the
- * server. The content of the message is application dependent, and the
- * mechanisms for constructing and parsing these messages is an
- * application-level task.
- */
- public static final byte SESSION_MESSAGE = 0x30;
-
- /**
- * Logout request from a client to a server.
- *
- * Opcode: {@code 0x40}
- *
- * No payload.
- *
- * This message will cause the client to be logged out of the server. The
- * server will remove all of the client's channel memberships. Any message
- * (other than {@link #LOGIN_REQUEST}) sent by the client after sending this
- * message will be ignored, and any message will need to be sent on a new
- * connection to the server.
- */
- public static final byte LOGOUT_REQUEST = 0x40;
-
- /**
- * Logout success. Server response to a client's {@link #LOGOUT_REQUEST}.
- *
- * Opcode: {@code 0x41}
- *
- * No payload.
- *
- * This message is sent from the server to the client to indicate that a
- * {@link #LOGOUT_REQUEST} has been received and that the client has been
- * logged out of the current session. On receipt of this message, the client
- * should shut down any networking resources that are used to communicate
- * with the server.
- */
- public static final byte LOGOUT_SUCCESS = 0x41;
-
- /**
- * Channel join. Server notifying a client that it has joined a channel.
- *
- * Opcode: {@code 0x50}
- *
- * Payload:
- *
- * - (String) channel name
- *
- (ByteArray) channel ID
- *
- * This message is sent from the server to the client to indicate that the
- * client has been added to the channel identified by the {@code channel
- * name} and {@code channel ID} contained in the message.
- */
- public static final byte CHANNEL_JOIN = 0x50;
-
- /**
- * Channel leave. Server notifying a client that the client has left a
- * channel.
- *
- * Opcode: {@code 0x51}
- *
- * Payload:
- *
- * - (ByteArray) channel ID
- *
- * This message is sent from the server indicating to the client that the
- * client has been removed from the channel with the indicated {@code
- * channel ID}. The client can no longer send messages on the channel.
- */
- public static final byte CHANNEL_LEAVE = 0x51;
-
- /**
- * Channel message. May be sent by the client or the server. Maximum length
- * is {@value #MAX_PAYLOAD_LENGTH} bytes minus the sum of the {@code
- * channel ID} size and two bytes (the size of the unsigned short indicating
- * the {@code channel Id} size). Larger messages require fragmentation and
- * reassembly above this protocol layer.
- *
- * Opcode: {@code 0x52}
- *
- * Payload:
- *
- * - (unsigned short) channel ID size
- *
- (ByteArray) channel ID
- *
- (ByteArray) message
- *
- * This message requests that the specified message be sent to all members
- * of the specified channel. If the client sending the request is not a
- * member of the channel, the message will be rejected by the server. The
- * server may also refuse to send the message, or alter the message, because
- * of application-specific logic.
- */
- public static final byte CHANNEL_MESSAGE = 0x52;
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/AbstractNettyServer.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/AbstractNettyServer.java
deleted file mode 100644
index 3a11ea72..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/AbstractNettyServer.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import java.net.InetSocketAddress;
-
-import org.jboss.netty.bootstrap.Bootstrap;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.group.ChannelGroup;
-import org.jboss.netty.channel.group.ChannelGroupFuture;
-import org.jboss.netty.channel.group.DefaultChannelGroup;
-import org.menacheri.jetserver.app.Session;
-import org.menacheri.jetserver.service.GameAdminService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Required;
-
-
-public abstract class AbstractNettyServer implements NettyServer
-{
- private static final Logger LOG = LoggerFactory.getLogger(AbstractNettyServer.class);
- public static final ChannelGroup ALL_CHANNELS = new DefaultChannelGroup("JETSERVER-CHANNELS");
- protected Session session;
- protected InetSocketAddress socketAddress;
- protected int portNumber = 18090;
- protected Bootstrap serverBootstrap;
- protected ChannelPipelineFactory pipelineFactory;
- protected GameAdminService gameAdminService;
-
- public AbstractNettyServer()
- {
- super();
- }
-
- @Override
- public void stopServer() throws Exception
- {
- LOG.debug("In stopServer method of class: {}",
- this.getClass().getName());
- ChannelGroupFuture future = ALL_CHANNELS.close();
- try {
- future.await();
- } catch (InterruptedException e) {
- LOG.error("Execption occurred while waiting for channels to close: {}",e);
- }
- serverBootstrap.releaseExternalResources();
- gameAdminService.shutdown();
- }
-
- @Override
- public void configureServerBootStrap(String[] optionsList)
- {
- // For clients who do not use spring.
- if(null == serverBootstrap){
- createServerBootstrap();
- }
- serverBootstrap.setPipelineFactory(pipelineFactory);
- if (null != optionsList && optionsList.length > 0)
- {
- for (String option : optionsList)
- {
- serverBootstrap.setOption(option, true);
- }
- }
- }
-
- public int getPortNumber(String[] args)
- {
- if (null == args || args.length < 1)
- {
- return portNumber;
- }
-
- try
- {
- return Integer.parseInt(args[0]);
- }
- catch (NumberFormatException e)
- {
- LOG.error("Exception occurred while "
- + "trying to parse the port number: {}", args[0]);
- LOG.error("NumberFormatException: {}",e);
- throw e;
- }
- }
-
- @Override
- public Bootstrap getServerBootstrap()
- {
- return serverBootstrap;
- }
-
- @Override
- public void setServerBootstrap(Bootstrap serverBootstrap)
- {
- this.serverBootstrap = serverBootstrap;
- }
-
- @Override
- public ChannelPipelineFactory getPipelineFactory()
- {
- return pipelineFactory;
- }
-
- @Override
- @Required
- public void setPipelineFactory(ChannelPipelineFactory factory)
- {
- pipelineFactory = factory;
- }
-
- public int getPortNumber()
- {
- return portNumber;
- }
-
- public void setPortNumber(int portNumber)
- {
- this.portNumber = portNumber;
- }
-
- public GameAdminService getGameAdminService()
- {
- return gameAdminService;
- }
-
- public void setGameAdminService(GameAdminService gameAdminService)
- {
- this.gameAdminService = gameAdminService;
- }
-
- @Override
- public InetSocketAddress getSocketAddress()
- {
- return socketAddress;
- }
-
- public void setInetAddress(InetSocketAddress inetAddress)
- {
- this.socketAddress = inetAddress;
- }
-
- @Override
- public String toString()
- {
- return "NettyServer [socketAddress=" + socketAddress + ", portNumber="
- + portNumber + "]";
- }
-
- @Override
- public Session getSession()
- {
- return session;
- }
-
- @Override
- public void setSession(Session session)
- {
- this.session = session;
- }
-
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/FlashPolicyServer.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/FlashPolicyServer.java
deleted file mode 100644
index b3a416c3..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/FlashPolicyServer.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import java.util.concurrent.Executors;
-
-import org.jboss.netty.bootstrap.Bootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-import org.menacheri.jetserver.concurrent.NamedThreadFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FlashPolicyServer extends NettyTCPServer
-{
- private static final Logger LOG = LoggerFactory.getLogger(FlashPolicyServer.class);
- private int portNumber = 843;
-
- public int getPortNumber(String[] args)
- {
- if (null == args || args.length != 2)
- {
- LOG.debug("Going to use port: {}", portNumber);
- return portNumber;
- }
-
- try
- {
- int portNumberArg = Integer.parseInt(args[1]);
- LOG.debug("Going to use port: {}", portNumberArg);
- return portNumberArg;
- }
- catch (NumberFormatException e)
- {
- LOG.error("Exception occurred while "
- + "trying to parse the port number: {}, {}", args[0], e);
- throw e;
- }
- }
-
- public Bootstrap createServerBootstrap()
- {
- // TODO The thread pools should be injected from spring.
- serverBootstrap = new ServerBootstrap(
-
- new NioServerSocketChannelFactory(Executors
- .newFixedThreadPool(1,new NamedThreadFactory(
- "Flash-Server-Boss")), Executors
- .newFixedThreadPool(1,new NamedThreadFactory(
- "Flash-Server-Worker"))));
-
- return serverBootstrap;
- }
-
- public int getPortNumber()
- {
- return portNumber;
- }
-
- public void setPortNumber(int portNumber)
- {
- this.portNumber = portNumber;
- }
-
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/FlashPolicyServerPipelineFactory.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/FlashPolicyServerPipelineFactory.java
deleted file mode 100644
index 423cdbfc..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/FlashPolicyServerPipelineFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import static org.jboss.netty.channel.Channels.pipeline;
-
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
-import org.jboss.netty.util.Timer;
-import org.menacheri.jetserver.handlers.netty.FlashPolicyServerDecoder;
-import org.menacheri.jetserver.handlers.netty.FlashPolicyServerHandler;
-
-
-/**
- * @author Bruce Mitchener
- */
-public class FlashPolicyServerPipelineFactory implements ChannelPipelineFactory
-{
- private Timer timer;
-
- public ChannelPipeline getPipeline() throws Exception {
- // Create a default pipeline implementation.
- ChannelPipeline pipeline = pipeline();
- pipeline.addLast("timeout", new ReadTimeoutHandler(timer, 30));
- pipeline.addLast("decoder", new FlashPolicyServerDecoder());
- pipeline.addLast("handler", getFlashPolicyServerHandler());
- return pipeline;
- }
-
- /**
- * Spring will return the actual prototype bean from its context here. It
- * uses method lookup here.
- *
- * @return a new instance of the {@link FlashPolicyServerHandler}
- */
- protected FlashPolicyServerHandler getFlashPolicyServerHandler()
- {
- return null;
- }
-
- public Timer getTimer()
- {
- return timer;
- }
-
- public void setTimer(Timer timer)
- {
- this.timer = timer;
- }
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/LoginPipelineFactory.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/LoginPipelineFactory.java
deleted file mode 100644
index c77917ef..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/LoginPipelineFactory.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import static org.jboss.netty.channel.Channels.pipeline;
-
-import org.jboss.netty.channel.ChannelHandler;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
-import org.jboss.netty.handler.codec.frame.LengthFieldPrepender;
-import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
-import org.jboss.netty.handler.timeout.IdleStateHandler;
-import org.jboss.netty.util.Timer;
-import org.menacheri.jetserver.handlers.netty.EventDecoder;
-import org.menacheri.jetserver.handlers.netty.LoginHandler;
-
-
-public class LoginPipelineFactory implements ChannelPipelineFactory
-{
- /**
- * TODO make this configurable
- */
- private static final int MAX_IDLE_SECONDS = 60;
- private int frameSize;
- private Timer timer;
- private IdleStateAwareChannelHandler idleCheckHandler;
- private EventDecoder eventDecoder;
- private LoginHandler loginHandler;
- private LengthFieldPrepender lengthFieldPrepender;
-
- @Override
- public ChannelPipeline getPipeline() throws Exception
- {
- // Create a default pipeline implementation.
- ChannelPipeline pipeline = pipeline();
- addHandlers(pipeline);
- return pipeline;
- }
-
- public ChannelPipeline addHandlers(ChannelPipeline pipeline)
- {
- if (null == pipeline)
- return null;
- pipeline.addLast("framer",createLengthBasedFrameDecoder());
- pipeline.addLast("idleStateCheck", new IdleStateHandler(timer, 0, 0,
- MAX_IDLE_SECONDS));
- pipeline.addLast("idleCheckHandler", idleCheckHandler);
- pipeline.addLast("eventDecoder", eventDecoder);
- pipeline.addLast("loginHandler", loginHandler);
- pipeline.addLast("lengthFieldPrepender",lengthFieldPrepender);
- return pipeline;
- }
-
- public ChannelHandler createLengthBasedFrameDecoder()
- {
- return new LengthFieldBasedFrameDecoder(frameSize, 0, 2, 0, 2);
- }
-
- public int getFrameSize()
- {
- return frameSize;
- }
-
- public void setFrameSize(int frameSize)
- {
- this.frameSize = frameSize;
- }
-
- public EventDecoder getEventDecoder()
- {
- return eventDecoder;
- }
-
- public void setEventDecoder(EventDecoder eventDecoder)
- {
- this.eventDecoder = eventDecoder;
- }
-
- public LoginHandler getLoginHandler()
- {
- return loginHandler;
- }
-
- public void setLoginHandler(LoginHandler loginHandler)
- {
- this.loginHandler = loginHandler;
- }
-
- public IdleStateAwareChannelHandler getIdleCheckHandler()
- {
- return idleCheckHandler;
- }
-
- public void setIdleCheckHandler(IdleStateAwareChannelHandler idleCheckHandler)
- {
- this.idleCheckHandler = idleCheckHandler;
- }
-
- public Timer getTimer()
- {
- return timer;
- }
-
- public void setTimer(Timer timer)
- {
- this.timer = timer;
- }
-
- public LengthFieldPrepender getLengthFieldPrepender()
- {
- return lengthFieldPrepender;
- }
-
- public void setLengthFieldPrepender(LengthFieldPrepender lengthFieldPrepender)
- {
- this.lengthFieldPrepender = lengthFieldPrepender;
- }
-
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyServer.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyServer.java
deleted file mode 100644
index 64b6fbf3..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyServer.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import org.jboss.netty.bootstrap.Bootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.menacheri.jetserver.server.Server;
-
-/**
- * An interface specific to the JBoss Netty implementation. It will be
- * implemented by a class that will start up a Netty server at a specified port.
- *
- * @author Abraham Menacherry
- *
- */
-public interface NettyServer extends Server
-{
- /**
- * Creates a {@link ServerBootstrap} object which is used to start a server.
- *
- * @return Returns the created {@link ServerBootstrap}.
- */
- public Bootstrap createServerBootstrap();
-
- /**
- * If thread pools or TCP/IP parameters or the pipeline factory need to be
- * modified then it is this method that needs to be overriden.
- *
- * @param optionsList
- * Used to set tcp ip options like noDelay etc.
- */
- public void configureServerBootStrap(String[] optionsList);
-
- /**
- * createServerBootstrap will create a pipeline factory and save it as a
- * class variable. This method can then be used to retrieve that value.
- *
- * @return Returns the channel pipeline factory that is associated with this
- * netty server.
- */
- public ChannelPipelineFactory getPipelineFactory();
-
- /**
- * Method can be used to set the pipeline factory that is to be used by the
- * netty server.
- *
- * @param factory
- * The factory which will create a pipeline on each incoming
- * connection.
- */
- public void setPipelineFactory(ChannelPipelineFactory factory);
-
- /**
- * @return Returns the created server bootstrap object.
- */
- public Bootstrap getServerBootstrap();
-
- /**
- * Sets the server bootstrap, could be TCP, UDP bootstrap.
- *
- * @param serverBootstrap
- */
- public void setServerBootstrap(Bootstrap serverBootstrap);
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyTCPServer.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyTCPServer.java
deleted file mode 100644
index fcee39ab..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyTCPServer.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.concurrent.Executors;
-
-import org.jboss.netty.bootstrap.Bootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelException;
-import org.jboss.netty.channel.group.ChannelGroupFuture;
-import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-import org.menacheri.jetserver.concurrent.NamedThreadFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * This class is used for TCP IP communications with client. It uses Netty tcp
- * server bootstrap for this.
- *
- * @author Abraham Menacherry
- *
- */
-public class NettyTCPServer extends AbstractNettyServer
-{
- private static final Logger LOG = LoggerFactory.getLogger(NettyTCPServer.class);
-
- private String[] args;
-
- public NettyTCPServer()
- {
-
- }
-
- public void startServer(int port) throws Exception
- {
- portNumber = port;
- startServer(args);
- }
-
- @Override
- public void startServer() throws Exception
- {
- startServer(args);
- }
-
- public void startServer(String[] args) throws Exception
- {
- int portNumber = getPortNumber(args);
- InetSocketAddress socketAddress = new InetSocketAddress(portNumber);
- startServer(socketAddress);
- }
-
- public Bootstrap createServerBootstrap()
- {
- // TODO The thread pools should be injected from spring.
- serverBootstrap = new ServerBootstrap(
- new NioServerSocketChannelFactory(Executors
- .newCachedThreadPool(new NamedThreadFactory(
- "TCP-Server-Boss")), Executors
- .newCachedThreadPool(new NamedThreadFactory(
- "TCP-Server-Worker"))));
-
- return serverBootstrap;
- }
-
- @Override
- public TransmissionProtocol getTransmissionProtocol()
- {
- return TRANSMISSION_PROTOCOL.TCP;
- }
-
- @Override
- public void startServer(InetSocketAddress socketAddress)
- {
- this.socketAddress = socketAddress;
- if (null == args || args.length == 0)
- {
- String[] optionsList = new String[2];
- optionsList[0] = "child.tcpNoDelay";
- optionsList[1] = "child.keepAlive";
- configureServerBootStrap(optionsList);
- }
- else
- {
- configureServerBootStrap(args);
- }
- try
- {
- ((ServerBootstrap) serverBootstrap).bind(socketAddress);
- }
- catch (ChannelException e)
- {
- LOG.error("Unable to start TCP server due to error {}",e);
- throw e;
- }
- }
-
- public void stopServer() throws Exception
- {
- LOG.debug("In stopServer method of class: {}",
- this.getClass().getName());
- ChannelGroupFuture future = ALL_CHANNELS.close();
- try {
- future.await();
- } catch (InterruptedException e) {
- LOG.error("Execption occurred while waiting for channels to close: {}",e);
- }
- super.stopServer();
- }
-
- public String[] getArgs()
- {
- return args;
- }
-
- public void setArgs(String[] args)
- {
- this.args = args;
- }
-
- @Override
- public String toString()
- {
- return "NettyTCPServer [args=" + Arrays.toString(args)
- + ", socketAddress=" + socketAddress + ", portNumber=" + portNumber
- + "]";
- }
-
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyUDPServer.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyUDPServer.java
deleted file mode 100644
index a1a80257..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/NettyUDPServer.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.concurrent.Executors;
-
-import org.jboss.netty.bootstrap.Bootstrap;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelException;
-import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory;
-import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
-import org.menacheri.jetserver.concurrent.NamedThreadFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * This server does UDP connection less broadcast. Since it does not store the
- * connection, each call to a channel write must also contain the remote socket
- * address e.getChannel().write("Message", e.getRemoteAddress()).
- * Since it uses the same channel for all incoming connections, the handlers
- * cannot be modified refer to nabble
- * post
- *
- * @author Abraham Menacherry
- *
- */
-public class NettyUDPServer extends AbstractNettyServer
-{
- private static final Logger LOG = LoggerFactory.getLogger(NettyUDPServer.class);
- private FixedReceiveBufferSizePredictorFactory bufferSizePredictor;
- private String[] args;
-
- /**
- * The connected channel for this server. This reference can be used to
- * shutdown this server.
- */
- private Channel channel;
-
- public NettyUDPServer()
- {
-
- }
-
- @Override
- public void startServer(int port) throws Exception
- {
- portNumber = port;
- startServer(args);
- }
-
- @Override
- public void startServer() throws Exception
- {
- startServer(args);
- }
-
- public void startServer(String[] args) throws Exception
- {
- int portNumber = getPortNumber(args);
- InetSocketAddress socketAddress = new InetSocketAddress(portNumber);
- startServer(socketAddress);
- }
-
- @Override
- public Bootstrap createServerBootstrap()
- {
- serverBootstrap = new ConnectionlessBootstrap(
- new NioDatagramChannelFactory(Executors
- .newCachedThreadPool(new NamedThreadFactory(
- "UDP-Server-Worker"))));
- return serverBootstrap;
- }
-
- @Override
- public void stopServer() throws Exception
- {
- if(null != channel)
- {
- channel.close();
- }
- super.stopServer();
- }
-
- public FixedReceiveBufferSizePredictorFactory getBufferSizePredictor()
- {
- return bufferSizePredictor;
- }
-
- public void setBufferSizePredictor(
- FixedReceiveBufferSizePredictorFactory bufferSizePredictor)
- {
- this.bufferSizePredictor = bufferSizePredictor;
- }
-
- @Override
- public TransmissionProtocol getTransmissionProtocol()
- {
- return TRANSMISSION_PROTOCOL.UDP;
- }
-
- @Override
- public void startServer(InetSocketAddress socketAddress)
- {
- this.socketAddress = socketAddress;
- //TODO these should be set from spring
- serverBootstrap.setOption("broadcast", "false");
- serverBootstrap.setOption("receiveBufferSizePredictorFactory",
- bufferSizePredictor);
- serverBootstrap.setOption("sendBufferSize", 65536);
- serverBootstrap.setOption("receiveBufferSize", 65536);
- configureServerBootStrap(args);
-
- try
- {
- channel = ((ConnectionlessBootstrap) serverBootstrap)
- .bind(socketAddress);
- }
- catch (ChannelException e)
- {
- LOG.error("Unable to start UDP server due to error {}",e);
- throw e;
- }
-
- }
-
- public String[] getArgs()
- {
- return args;
- }
-
- public void setArgs(String[] args)
- {
- this.args = args;
- }
-
- @Override
- public String toString()
- {
- return "NettyUDPServer [args=" + Arrays.toString(args)
- + ", socketAddress=" + socketAddress + ", portNumber=" + portNumber
- + "]";
- }
-
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/ProtocolMultiplexerPipelineFactory.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/ProtocolMultiplexerPipelineFactory.java
deleted file mode 100644
index f94aa5cf..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/ProtocolMultiplexerPipelineFactory.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import static org.jboss.netty.channel.Channels.pipeline;
-
-import org.jboss.netty.channel.ChannelHandler;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
-import org.jboss.netty.handler.timeout.IdleStateHandler;
-import org.jboss.netty.util.Timer;
-import org.menacheri.jetserver.handlers.netty.LoginProtocol;
-import org.menacheri.jetserver.handlers.netty.ProtocolMultiplexerDecoder;
-
-public class ProtocolMultiplexerPipelineFactory implements
- ChannelPipelineFactory
-{
- private static final int MAX_IDLE_SECONDS = 60;
- private Timer timer;
- private IdleStateAwareChannelHandler idleCheckHandler;
- private int bytesForProtocolCheck;
- private LoginProtocol loginProtocol;
-
- @Override
- public ChannelPipeline getPipeline() throws Exception
- {
- // Create a default pipeline implementation.
- ChannelPipeline pipeline = pipeline();
- pipeline.addLast("idleStateCheck", new IdleStateHandler(timer, 0, 0,
- MAX_IDLE_SECONDS));
- pipeline.addLast("idleCheckHandler", idleCheckHandler);
- pipeline.addLast("multiplexer", createProtcolMultiplexerDecoder());
- return pipeline;
- }
-
- protected ChannelHandler createProtcolMultiplexerDecoder()
- {
- return new ProtocolMultiplexerDecoder(bytesForProtocolCheck,loginProtocol);
- }
-
- public Timer getTimer()
- {
- return timer;
- }
-
- public void setTimer(Timer timer)
- {
- this.timer = timer;
- }
-
- public IdleStateAwareChannelHandler getIdleCheckHandler()
- {
- return idleCheckHandler;
- }
-
- public void setIdleCheckHandler(IdleStateAwareChannelHandler idleCheckHandler)
- {
- this.idleCheckHandler = idleCheckHandler;
- }
-
- public int getBytesForProtocolCheck()
- {
- return bytesForProtocolCheck;
- }
-
- public void setBytesForProtocolCheck(int bytesForProtocolCheck)
- {
- this.bytesForProtocolCheck = bytesForProtocolCheck;
- }
-
- public LoginProtocol getLoginProtocol()
- {
- return loginProtocol;
- }
-
- public void setLoginProtocol(LoginProtocol loginProtocol)
- {
- this.loginProtocol = loginProtocol;
- }
-}
diff --git a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/UDPChannelPipelineFactory.java b/jetserver/src/main/java/org/menacheri/jetserver/server/netty/UDPChannelPipelineFactory.java
deleted file mode 100644
index bd3e5733..00000000
--- a/jetserver/src/main/java/org/menacheri/jetserver/server/netty/UDPChannelPipelineFactory.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.menacheri.jetserver.server.netty;
-
-import static org.jboss.netty.channel.Channels.pipeline;
-
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.menacheri.jetserver.handlers.netty.MessageBufferEventDecoder;
-import org.menacheri.jetserver.handlers.netty.MessageBufferEventEncoder;
-import org.menacheri.jetserver.handlers.netty.UDPUpstreamHandler;
-
-
-public class UDPChannelPipelineFactory implements ChannelPipelineFactory
-{
- /**
- * This pipeline will be shared across all the channels. In Netty UDP
- * implementation it does not make sense to have different pipelines for
- * different channels as the protocol is essentials "connection-less"
- */
- ChannelPipeline pipeline;
- /**
- * The Message buffer event decoder and encoder for the pipeline.
- */
- private MessageBufferEventDecoder messageBufferEventDecoder;
- private MessageBufferEventEncoder messageBufferEventEncoder;
-
- // Create a default pipeline implementation.
- private UDPUpstreamHandler upstream;
-
- public UDPChannelPipelineFactory()
- {
-
- }
-
- public UDPChannelPipelineFactory(UDPUpstreamHandler upstream)
- {
- this.upstream = upstream;
- }
-
- /**
- * This method creates a single pipeline object that will be shared for all
- * the channels.
- */
- public void init()
- {
- pipeline = pipeline();
-
- pipeline.addLast("messageBufferEventDecoder", messageBufferEventDecoder);
- pipeline.addLast("upstream", upstream);
-
- // Downstream handlers - Filter for data which flows from server to
- // client. Note that the last handler added is actually the first
- // handler for outgoing data.
- pipeline.addLast("messageBufferEventEncoder",messageBufferEventEncoder);
- }
-
- @Override
- public ChannelPipeline getPipeline() throws Exception
- {
- return pipeline;
- }
-
- public void setUpstream(UDPUpstreamHandler upstream)
- {
- this.upstream = upstream;
- }
-
- public MessageBufferEventDecoder getMessageBufferEventDecoder()
- {
- return messageBufferEventDecoder;
- }
-
- public void setMessageBufferEventDecoder(
- MessageBufferEventDecoder messageBufferEventDecoder)
- {
- this.messageBufferEventDecoder = messageBufferEventDecoder;
- }
-
- public MessageBufferEventEncoder getMessageBufferEventEncoder()
- {
- return messageBufferEventEncoder;
- }
-
- public void setMessageBufferEventEncoder(
- MessageBufferEventEncoder messageBufferEventEncoder)
- {
- this.messageBufferEventEncoder = messageBufferEventEncoder;
- }
-
- public UDPUpstreamHandler getUpstream()
- {
- return upstream;
- }
-
-}
diff --git a/jetserver/src/main/resources/jetserver/beans/netty-handlers.xml b/jetserver/src/main/resources/jetserver/beans/netty-handlers.xml
deleted file mode 100644
index 584fc706..00000000
--- a/jetserver/src/main/resources/jetserver/beans/netty-handlers.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jetserver/src/main/resources/jetserver/beans/server-beans.xml b/jetserver/src/main/resources/jetserver/beans/server-beans.xml
deleted file mode 100644
index 371c2765..00000000
--- a/jetserver/src/main/resources/jetserver/beans/server-beans.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jetserver/src/main/resources/jetserver/beans/server-protocols.xml b/jetserver/src/main/resources/jetserver/beans/server-protocols.xml
deleted file mode 100644
index 2a5bb30c..00000000
--- a/jetserver/src/main/resources/jetserver/beans/server-protocols.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jetserver/src/main/resources/jetserver/beans/service-beans.xml b/jetserver/src/main/resources/jetserver/beans/service-beans.xml
deleted file mode 100644
index 1dda923e..00000000
--- a/jetserver/src/main/resources/jetserver/beans/service-beans.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jetserver/src/main/resources/jetserver/props/jetserver.properties b/jetserver/src/main/resources/jetserver/props/jetserver.properties
deleted file mode 100644
index 75422787..00000000
--- a/jetserver/src/main/resources/jetserver/props/jetserver.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-flash.policy.port=843
-tcp.port=18090
-udp.port=18090
-reconnect.delay=300000
\ No newline at end of file
diff --git a/jetserver/src/test/java/org/menacheri/jetserver/protocols/impl/AMF3StringProtocolTest.java b/jetserver/src/test/java/org/menacheri/jetserver/protocols/impl/AMF3StringProtocolTest.java
deleted file mode 100644
index 369ac3c6..00000000
--- a/jetserver/src/test/java/org/menacheri/jetserver/protocols/impl/AMF3StringProtocolTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.menacheri.jetserver.protocols.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.handler.codec.base64.Base64Decoder;
-import org.jboss.netty.handler.codec.base64.Base64Encoder;
-import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
-import org.jboss.netty.handler.codec.embedder.EncoderEmbedder;
-import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
-import org.jboss.netty.handler.codec.frame.Delimiters;
-import org.junit.Before;
-import org.junit.Test;
-import org.menacheri.jetserver.communication.NettyMessageBuffer;
-import org.menacheri.jetserver.event.Events;
-import org.menacheri.jetserver.event.Event;
-import org.menacheri.jetserver.handlers.netty.AMF3ToJavaObjectDecoder;
-import org.menacheri.jetserver.handlers.netty.JavaObjectToAMF3Encoder;
-import org.menacheri.jetserver.handlers.netty.NulEncoder;
-import org.menacheri.jetserver.protocols.impl.AMF3StringProtocol;
-
-public class AMF3StringProtocolTest {
-
- private AMF3StringProtocol amf3StringProtocol;
- private DelimiterBasedFrameDecoder delimiterDecoder;
- @Before
- public void setUp()
- {
- amf3StringProtocol = new AMF3StringProtocol();
- amf3StringProtocol.setMaxFrameSize(1024);
- delimiterDecoder = new DelimiterBasedFrameDecoder(amf3StringProtocol.getMaxFrameSize(),
- Delimiters.nulDelimiter());
- amf3StringProtocol.setBase64Decoder(new Base64Decoder());
- amf3StringProtocol.setAmf3ToJavaObjectDecoder(new AMF3ToJavaObjectDecoder());
- amf3StringProtocol.setNulEncoder(new NulEncoder());
- amf3StringProtocol.setBase64Encoder(new Base64Encoder());
- amf3StringProtocol.setJavaObjectToAMF3Encoder(new JavaObjectToAMF3Encoder());
- }
-
- @Test
- public void verifyAMF3StringEncodingAndDecoding() throws InterruptedException
- {
- DecoderEmbedder decoder = new DecoderEmbedder(
- delimiterDecoder, amf3StringProtocol.getBase64Decoder(),
- amf3StringProtocol.getAmf3ToJavaObjectDecoder());
-
- EncoderEmbedder encoder = new EncoderEmbedder(
- amf3StringProtocol.getNulEncoder(),
- amf3StringProtocol.getBase64Encoder(),
- amf3StringProtocol.getJavaObjectToAMF3Encoder());
-
- NettyMessageBuffer payload = new NettyMessageBuffer();
- payload.writeStrings("user","pass","TestRoom1");
-
- Event event = Events.event(payload, Events.LOG_IN);
- encoder.offer(event);
- ChannelBuffer encoded = encoder.peek();
-
- Thread.sleep(10);// despite delay the timestamps should be same since we are decoding the whole object.
- decoder.offer(encoded);
- Event decoded = decoder.peek();
- assertEquals(decoded.getType(),Events.LOG_IN);
- assertTrue("Timestamps should be same" ,decoded.getTimeStamp() == event.getTimeStamp());
- NettyMessageBuffer decodedPayload = (NettyMessageBuffer)decoded.getSource();
- // NettyMessageBuffer will not get de-serialized properly.
- assertNull(decodedPayload.readString());
- }
-}
diff --git a/jetserver/src/test/java/org/menacheri/jetserver/protocols/impl/MessageBufferProtocolTest.java b/jetserver/src/test/java/org/menacheri/jetserver/protocols/impl/MessageBufferProtocolTest.java
deleted file mode 100644
index 8eb92a8f..00000000
--- a/jetserver/src/test/java/org/menacheri/jetserver/protocols/impl/MessageBufferProtocolTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.menacheri.jetserver.protocols.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
-import org.jboss.netty.handler.codec.embedder.EncoderEmbedder;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
-import org.jboss.netty.handler.codec.frame.LengthFieldPrepender;
-import org.junit.Before;
-import org.junit.Test;
-import org.menacheri.jetserver.communication.NettyMessageBuffer;
-import org.menacheri.jetserver.event.Events;
-import org.menacheri.jetserver.event.Event;
-import org.menacheri.jetserver.handlers.netty.MessageBufferEventDecoder;
-import org.menacheri.jetserver.handlers.netty.MessageBufferEventEncoder;
-import org.menacheri.jetserver.protocols.impl.MessageBufferProtocol;
-
-public class MessageBufferProtocolTest {
-
- private MessageBufferProtocol messageBufferProtocol;
- private LengthFieldBasedFrameDecoder frameDecoder;
-
- @Before
- public void setUp()
- {
- messageBufferProtocol = new MessageBufferProtocol();
- messageBufferProtocol.setLengthFieldPrepender(new LengthFieldPrepender(2, false));
- messageBufferProtocol.setMessageBufferEventDecoder(new MessageBufferEventDecoder());
- messageBufferProtocol.setMessageBufferEventEncoder(new MessageBufferEventEncoder());
- frameDecoder = messageBufferProtocol.createLengthBasedFrameDecoder();
- }
-
- @Test
- public void verifyEventEncodingAndDecoding() throws InterruptedException
- {
- DecoderEmbedder decoder = new DecoderEmbedder(
- frameDecoder,
- messageBufferProtocol.getMessageBufferEventDecoder());
- EncoderEmbedder encoder = new EncoderEmbedder(
- messageBufferProtocol.getLengthFieldPrepender(),
- messageBufferProtocol.getMessageBufferEventEncoder());
- NettyMessageBuffer payload = new NettyMessageBuffer();
- payload.writeStrings("user","pass","TestRoom1");
- Event event = Events.event(payload, Events.LOG_IN);
- encoder.offer(event);
- ChannelBuffer encoded = encoder.peek();
-
- Thread.sleep(100);// so that timestamps will differ.
- decoder.offer(encoded);
- Event decoded = decoder.peek();
- assertEquals(decoded.getType(),Events.LOG_IN);
- assertFalse("Timestamps should not be same",decoded.getTimeStamp() == event.getTimeStamp());
- NettyMessageBuffer decodedPayload = (NettyMessageBuffer)decoded.getSource();
- assertEquals("user",decodedPayload.readString());
- assertEquals("pass",decodedPayload.readString());
- assertEquals("TestRoom1",decodedPayload.readString());
- }
-}
diff --git a/jetserver/src/test/java/org/menacheri/jetserver/util/SessionHandlerLatchCounter.java b/jetserver/src/test/java/org/menacheri/jetserver/util/SessionHandlerLatchCounter.java
deleted file mode 100644
index 9acd07c6..00000000
--- a/jetserver/src/test/java/org/menacheri/jetserver/util/SessionHandlerLatchCounter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.menacheri.jetserver.util;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.menacheri.jetserver.app.Session;
-import org.menacheri.jetserver.event.NetworkEvent;
-import org.menacheri.jetserver.event.impl.DefaultSessionEventHandler;
-
-public class SessionHandlerLatchCounter extends DefaultSessionEventHandler {
-
- private final AtomicLong counter;
- private final CountDownLatch latch;
-
- public SessionHandlerLatchCounter(Session session, AtomicLong counter,
- CountDownLatch latch) {
- super(session);
- this.counter = counter;
- this.latch = latch;
- }
-
- @Override
- public void onNetworkMessage(NetworkEvent event) {
- counter.incrementAndGet();
- latch.countDown();
- }
-
- public AtomicLong getCounter() {
- return counter;
- }
-
- public CountDownLatch getLatch() {
- return latch;
- }
-
-}
diff --git a/jetclient-js/README.md b/nadclient-js/README.md
similarity index 56%
rename from jetclient-js/README.md
rename to nadclient-js/README.md
index 973c41f1..94f9ed39 100644
--- a/jetclient-js/README.md
+++ b/nadclient-js/README.md
@@ -1,15 +1,15 @@
-This is a **Javascript** client project for [jetserver](https://github.com/menacher/java-game-server/tree/master/jetserver) library. An example html which can connect to a locally running Jetserver is located at **test/jetclient.html**.
+This is a **Javascript** client project for [Nadron](https://github.com/menacher/java-game-server/tree/netty4/nadron) library. An example html which can connect to a locally running Nadron is located at **test/nadclient.html**.
About the Client
================
-Click on `Start War!` button after loading jetclient.html in a websocket compatible browser to start the game. Assumption is that Jetserver is running and jetclient.html is using accurate hostname and port number.
+Click on `Start War!` button after loading jetclient.html in a websocket compatible browser to start the game. Assumption is that Nadron server is running and nadclient.html is using accurate hostname and port number.
Usage as your own game client
=============================
The general usage steps could be as outlined below.
1. Create a `config` object containing the `user`, `password` and `connectionkey` to connect to game room. If you are using a different protocol, then add the appropriate `CodeChain`'s also to the `config` object. By default `JSon` encoding/decoding is used.
-2. Create a `session`(s) using the `SessionFactory` by passing in a `url` for the remote jetserver, `config` object and a `callback` function which will receive the `session` object after successful login to remote jeteserver.
-3. Add necessary handlers to the session using `addHandler` function. The default events are provided the `jet` class for e.g `jet.lOG_IN`. At the very least you would want to add a handler for the `jet.SESSION_MESSAGE` event to receive incoming events from jetserver.
+2. Create a `session`(s) using the `SessionFactory` by passing in a `url` for the remote Nadron server, `config` object and a `callback` function which will receive the `session` object after successful login to remote Nadron server.
+3. Add necessary handlers to the session using `addHandler` function. The default events are provided the `nad` class for e.g `nad.lOG_IN`. At the very least you would want to add a handler for the `nad.SESSION_MESSAGE` event to receive incoming events from jetserver.
4. Event objects to be sent to server can be created using the `jet.nevent` function.
5. Data can be send to remote server using `session.send` function.
diff --git a/jetclient-js/src/jet-0.1.js b/nadclient-js/src/nad-0.1.js
similarity index 69%
rename from jetclient-js/src/jet-0.1.js
rename to nadclient-js/src/nad-0.1.js
index d7be0b9c..7356aa2d 100644
--- a/jetclient-js/src/jet-0.1.js
+++ b/nadclient-js/src/nad-0.1.js
@@ -1,42 +1,42 @@
-(function (jet) {
+(function (nad) {
"use strict";
// Event code Constants
- jet.ANY = 0x00;
- jet.PROTOCOL_VERSION = 0x01;
+ nad.ANY = 0x00;
+ nad.PROTOCOL_VERSION = 0x01;
- jet.CONNECT = 0x02;
- jet.RECONNECT = 0x03;
- jet.CONNECT_FAILED = 0x06;
- jet.LOG_IN = 0x08;
- jet.LOG_OUT = 0x0a;
- jet.LOG_IN_SUCCESS = 0x0b;
- jet.LOG_IN_FAILURE = 0x0c;
- jet.LOG_OUT_SUCCESS = 0x0e;
- jet.LOG_OUT_FAILURE = 0x0f;
+ nad.CONNECT = 0x02;
+ nad.RECONNECT = 0x03;
+ nad.CONNECT_FAILED = 0x06;
+ nad.LOG_IN = 0x08;
+ nad.LOG_OUT = 0x0a;
+ nad.LOG_IN_SUCCESS = 0x0b;
+ nad.LOG_IN_FAILURE = 0x0c;
+ nad.LOG_OUT_SUCCESS = 0x0e;
+ nad.LOG_OUT_FAILURE = 0x0f;
- jet.GAME_LIST = 0x10;
- jet.ROOM_LIST = 0x12;
- jet.GAME_ROOM_JOIN = 0x14;
- jet.GAME_ROOM_LEAVE = 0x16;
- jet.GAME_ROOM_JOIN_SUCCESS = 0x18;
- jet.GAME_ROOM_JOIN_FAILURE = 0x19;
+ nad.GAME_LIST = 0x10;
+ nad.ROOM_LIST = 0x12;
+ nad.GAME_ROOM_JOIN = 0x14;
+ nad.GAME_ROOM_LEAVE = 0x16;
+ nad.GAME_ROOM_JOIN_SUCCESS = 0x18;
+ nad.GAME_ROOM_JOIN_FAILURE = 0x19;
//Event sent from server to client to start message sending from client to server.
- jet.START = 0x1a;
+ nad.START = 0x1a;
// Event sent from server to client to stop messages from being sent to server.
- jet.STOP = 0x1b;
+ nad.STOP = 0x1b;
// Incoming data from server or from another session.
- jet.SESSION_MESSAGE = 0x1c;
+ nad.SESSION_MESSAGE = 0x1c;
// This event is used to send data from the current machine to remote server
- jet.NETWORK_MESSAGE = 0x1d;
- jet.CHANGE_ATTRIBUTE = 0x20;
- jet.DISCONNECT = 0x22;// Use this one for handling close event of ws.
- jet.EXCEPTION = 0x24;
+ nad.NETWORK_MESSAGE = 0x1d;
+ nad.CHANGE_ATTRIBUTE = 0x20;
+ nad.DISCONNECT = 0x22;// Use this one for handling close event of ws.
+ nad.EXCEPTION = 0x24;
// Functions
// Creates a new event object
- jet.NEvent = function (eventType, payload, session, date) {
+ nad.NEvent = function (eventType, payload, session, date) {
return {
type : eventType,
source : payload,
@@ -45,17 +45,26 @@
};
};
- // Creates a login event object to login to remote jetserver
- jet.LoginEvent = function (config) {
- return jet.NEvent(jet.LOG_IN, [config.user, config.pass, config.connectionKey]);
+ //Special event creation function to send the json class name to Nadron server.
+ nad.CNameEvent = function (className) {
+ return {
+ type : nad.NETWORK_MESSAGE,
+ cName : className,
+ timeStamp : new Date().getTime()
+ };
+ };
+
+ // Creates a login event object to login to remote Nadron server
+ nad.LoginEvent = function (config) {
+ return nad.NEvent(nad.LOG_IN, [config.user, config.pass, config.connectionKey]);
};
// If using a differnt protocol, then use this codec chain, to decode and encode incoming and outgoing requests. Something like a Chain of Responsibility pattern.
- jet.CodecChain = function () {
+ nad.CodecChain = function () {
this.chain = [];
};
- jet.CodecChain.prototype.add = function (func) {
+ nad.CodecChain.prototype.add = function (func) {
if (func && typeof (func) === 'function') {
this.chain.push(func);
} else {
@@ -64,11 +73,11 @@
return this;
};
- jet.CodecChain.prototype.remove = function (func) {
+ nad.CodecChain.prototype.remove = function (func) {
removeFromArray(this.chain, func);
};
- jet.CodecChain.prototype.tranform = function (message) {
+ nad.CodecChain.prototype.tranform = function (message) {
var i = 0;
for(;i
+
+
+
+ Simple Canvas Game
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nadclient-js/test/images/background.png b/nadclient-js/test/images/background.png
new file mode 100644
index 00000000..eaeb8878
Binary files /dev/null and b/nadclient-js/test/images/background.png differ
diff --git a/nadclient-js/test/images/hero.png b/nadclient-js/test/images/hero.png
new file mode 100644
index 00000000..3cc1bd38
Binary files /dev/null and b/nadclient-js/test/images/hero.png differ
diff --git a/nadclient-js/test/images/hero2.png b/nadclient-js/test/images/hero2.png
new file mode 100644
index 00000000..c7eb7202
Binary files /dev/null and b/nadclient-js/test/images/hero2.png differ
diff --git a/nadclient-js/test/images/monster.png b/nadclient-js/test/images/monster.png
new file mode 100644
index 00000000..ef7cc0de
Binary files /dev/null and b/nadclient-js/test/images/monster.png differ
diff --git a/jetclient-js/test/jetclient.html b/nadclient-js/test/nadclient.html
similarity index 77%
rename from jetclient-js/test/jetclient.html
rename to nadclient-js/test/nadclient.html
index 0dd4827c..6949e8f1 100644
--- a/jetclient-js/test/jetclient.html
+++ b/nadclient-js/test/nadclient.html
@@ -1,7 +1,7 @@
-
+