-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #29 Allow for varied login protocols using a login multiplexer
decoder in conjunction with the port unification example
- Loading branch information
Showing
12 changed files
with
794 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 61 additions & 52 deletions
113
...lient/src/main/java/org/menacheri/jetclient/handlers/netty/MessageBufferEventEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,61 @@ | ||
package org.menacheri.jetclient.handlers.netty; | ||
|
||
import org.jboss.netty.buffer.ChannelBuffer; | ||
import org.jboss.netty.buffer.ChannelBuffers; | ||
import org.jboss.netty.channel.Channel; | ||
import org.jboss.netty.channel.ChannelHandler.Sharable; | ||
import org.jboss.netty.channel.ChannelHandlerContext; | ||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; | ||
import org.menacheri.jetclient.communication.MessageBuffer; | ||
import org.menacheri.jetclient.event.Event; | ||
|
||
/** | ||
* Converts an incoming {@link Event} which in turn has a | ||
* IMessageBuffer<ChannelBuffer> payload to a Netty {@link ChannelBuffer}. | ||
* <b>Note that {@link Event} instances containing other type of objects as its | ||
* payload will result in {@link ClassCastException}. | ||
* | ||
* @author Abraham Menacherry. | ||
* | ||
*/ | ||
@Sharable | ||
public class MessageBufferEventEncoder extends OneToOneEncoder | ||
{ | ||
|
||
@Override | ||
protected Object encode(ChannelHandlerContext ctx, Channel channel, | ||
Object msg) throws Exception | ||
{ | ||
if (null == msg) | ||
{ | ||
return msg; | ||
} | ||
Event event = (Event) msg; | ||
ChannelBuffer opCode = ChannelBuffers.buffer(1); | ||
opCode.writeByte(event.getType()); | ||
ChannelBuffer buffer = null; | ||
if (null != event.getSource()) | ||
{ | ||
@SuppressWarnings("unchecked") | ||
MessageBuffer<ChannelBuffer> msgBuffer = (MessageBuffer<ChannelBuffer>) event | ||
.getSource(); | ||
ChannelBuffer data = msgBuffer.getNativeBuffer(); | ||
buffer = ChannelBuffers.wrappedBuffer(opCode, data); | ||
} | ||
else | ||
{ | ||
buffer = opCode; | ||
} | ||
return buffer; | ||
} | ||
|
||
} | ||
package org.menacheri.jetclient.handlers.netty; | ||
|
||
import org.jboss.netty.buffer.ChannelBuffer; | ||
import org.jboss.netty.buffer.ChannelBuffers; | ||
import org.jboss.netty.channel.Channel; | ||
import org.jboss.netty.channel.ChannelHandler.Sharable; | ||
import org.jboss.netty.channel.ChannelHandlerContext; | ||
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; | ||
import org.menacheri.jetclient.communication.MessageBuffer; | ||
import org.menacheri.jetclient.event.Event; | ||
import org.menacheri.jetclient.event.Events; | ||
|
||
/** | ||
* Converts an incoming {@link Event} which in turn has a | ||
* IMessageBuffer<ChannelBuffer> payload to a Netty {@link ChannelBuffer}. | ||
* <b>Note that {@link Event} instances containing other type of objects as its | ||
* payload will result in {@link ClassCastException}. | ||
* | ||
* @author Abraham Menacherry. | ||
* | ||
*/ | ||
@Sharable | ||
public class MessageBufferEventEncoder extends OneToOneEncoder | ||
{ | ||
|
||
@Override | ||
protected Object encode(ChannelHandlerContext ctx, Channel channel, | ||
Object msg) throws Exception | ||
{ | ||
if (null == msg) | ||
{ | ||
return msg; | ||
} | ||
Event event = (Event) msg; | ||
ChannelBuffer opCode = ChannelBuffers.buffer(1); | ||
opCode.writeByte(event.getType()); | ||
if (Events.LOG_IN == event.getType()) | ||
{ | ||
// write protocol version also | ||
ChannelBuffer protocolVersion = ChannelBuffers.buffer(1); | ||
protocolVersion.writeByte(Events.PROTOCOL_VERSION); | ||
opCode = ChannelBuffers.wrappedBuffer(opCode, protocolVersion); | ||
} | ||
|
||
ChannelBuffer buffer = null; | ||
if (null != event.getSource()) | ||
{ | ||
@SuppressWarnings("unchecked") | ||
MessageBuffer<ChannelBuffer> msgBuffer = (MessageBuffer<ChannelBuffer>) event | ||
.getSource(); | ||
ChannelBuffer data = msgBuffer.getNativeBuffer(); | ||
buffer = ChannelBuffers.wrappedBuffer(opCode, data); | ||
} | ||
else | ||
{ | ||
buffer = opCode; | ||
} | ||
return buffer; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
<classpath> | ||
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.aj|**/*.java|**/*.aj"/> | ||
<classpathentry kind="src" path="src/main/java" including="**/*.aj|**/*.java|**/*.aj"/> | ||
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
<classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar" sourcepath="M2_REPO/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/com/adobe/blazeds/blazeds-common/3.2.0.3978/blazeds-common-3.2.0.3978.jar" sourcepath="M2_REPO/com/adobe/blazeds/blazeds-common/3.2.0.3978/blazeds-common-3.2.0.3978-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/com/adobe/blazeds/blazeds-core/3.2.0.3978/blazeds-core-3.2.0.3978.jar" sourcepath="M2_REPO/com/adobe/blazeds/blazeds-core/3.2.0.3978/blazeds-core-3.2.0.3978-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar" sourcepath="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/org/jetlang/jetlang/0.2.9/jetlang-0.2.9.jar" sourcepath="M2_REPO/org/jetlang/jetlang/0.2.9/jetlang-0.2.9-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/org/jetlang/jetlang/0.2.9/jetlang-0.2.9-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/junit/junit/4.8.2/junit-4.8.2.jar" sourcepath="M2_REPO/junit/junit/4.8.2/junit-4.8.2-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/junit/junit/4.8.2/junit-4.8.2-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar" sourcepath="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/io/netty/netty/3.3.1.Final/netty-3.3.1.Final.jar" sourcepath="M2_REPO/io/netty/netty/3.3.1.Final/netty-3.3.1.Final-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/io/netty/netty/3.3.1.Final/netty-3.3.1.Final-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-aop/3.1.0.RELEASE/spring-aop-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-aop/3.1.0.RELEASE/spring-aop-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-beans/3.1.0.RELEASE/spring-beans-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-beans/3.1.0.RELEASE/spring-beans-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-context/3.1.0.RELEASE/spring-context-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-context/3.1.0.RELEASE/spring-context-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-expression/3.1.0.RELEASE/spring-expression-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-expression/3.1.0.RELEASE/spring-expression-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/> | ||
<classpath> | ||
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.aj|**/*.java|**/*.aj"/> | ||
<classpathentry kind="src" path="src/main/java" including="**/*.aj|**/*.java|**/*.aj"/> | ||
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
<classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar" sourcepath="M2_REPO/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Users/aby/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/com/adobe/blazeds/blazeds-common/3.2.0.3978/blazeds-common-3.2.0.3978.jar" sourcepath="M2_REPO/com/adobe/blazeds/blazeds-common/3.2.0.3978/blazeds-common-3.2.0.3978-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/com/adobe/blazeds/blazeds-core/3.2.0.3978/blazeds-core-3.2.0.3978.jar" sourcepath="M2_REPO/com/adobe/blazeds/blazeds-core/3.2.0.3978/blazeds-core-3.2.0.3978-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar" sourcepath="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Users/aby/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/org/jetlang/jetlang/0.2.9/jetlang-0.2.9.jar" sourcepath="M2_REPO/org/jetlang/jetlang/0.2.9/jetlang-0.2.9-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Users/aby/.m2/repository/org/jetlang/jetlang/0.2.9/jetlang-0.2.9-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/junit/junit/4.8.2/junit-4.8.2.jar" sourcepath="M2_REPO/junit/junit/4.8.2/junit-4.8.2-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Users/aby/.m2/repository/junit/junit/4.8.2/junit-4.8.2-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar" sourcepath="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Users/aby/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/io/netty/netty/3.5.11.Final/netty-3.5.11.Final.jar" sourcepath="M2_REPO/io/netty/netty/3.5.11.Final/netty-3.5.11.Final-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Users/aby/.m2/repository/io/netty/netty/3.5.11.Final/netty-3.5.11.Final-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Users/aby/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1-sources.jar"> | ||
<attributes> | ||
<attribute value="jar:file:/C:/Users/aby/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1-javadoc.jar!/" name="javadoc_location"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-aop/3.1.0.RELEASE/spring-aop-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-aop/3.1.0.RELEASE/spring-aop-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-asm/3.1.0.RELEASE/spring-asm-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-beans/3.1.0.RELEASE/spring-beans-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-beans/3.1.0.RELEASE/spring-beans-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-context/3.1.0.RELEASE/spring-context-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-context/3.1.0.RELEASE/spring-context-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-core/3.1.0.RELEASE/spring-core-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="var" path="M2_REPO/org/springframework/spring-expression/3.1.0.RELEASE/spring-expression-3.1.0.RELEASE.jar" sourcepath="M2_REPO/org/springframework/spring-expression/3.1.0.RELEASE/spring-expression-3.1.0.RELEASE-sources.jar"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<projectDescription> | ||
<name>jetserver</name> | ||
<comment>Jetserver is a high speed socket based java game server written using JBoss Netty and Mike Rettig's Jetlang.It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment> | ||
<projects/> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.ajdt.core.ajbuilder</name> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.ajdt.ui.ajnature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.springframework.ide.eclipse.core.springnature</nature> | ||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> | ||
</natures> | ||
<projectDescription> | ||
<name>jetserver</name> | ||
<comment>Jetserver is a high speed socket based java game server written using JBoss Netty and Mike Rettig's Jetlang.It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment> | ||
<projects/> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.ajdt.core.ajbuilder</name> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.ajdt.ui.ajnature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.springframework.ide.eclipse.core.springnature</nature> | ||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> | ||
</natures> | ||
</projectDescription> |
Oops, something went wrong.