Jetserver is a high speed nio socket based multiplayer java game server written using Netty and Mike Rettig's Jetlang.It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols.

Overview

Note New version of Jetserver is called Nadron and is in a new netty 4 branch of this same repo.
JetServer is a java nio based server specifically designed for mutliplayer games. It supports UDP and TCP transports. It uses Netty for high speed network transmission and Jetlang for extremely fast in-vm message passing between player sessions and game rooms. The project also uses spring for its dependency injection. This way, it is highly configurable and you can swap out any part of the server with your own implementations.

Wiki

The wiki provides implementation level details and answers to general questions that a developer starting to use jetserver might have about it. The following blog has post on game creation.

Support Group

For general discussion please use the jetserver google group. Issues and bugs can be raised directly in github.

Installation

Maven

<dependency>
    <groupId>com.github.menacher</groupId>
    <artifactId>nadron</artifactId>
    <version>0.5</version>
</dependency>

From Source

Using pre-built jar files

The pre-built jar files of this project are located in the jetserver/binaries directory. All dependent jars are located in the jetserver/lib directory. You can add them to your favorite IDE’s classpath for coding. If you want to compile from source, then follow steps below.

With Maven and using Eclipse

Pre-requisites: Please have maven 3+ and Spring source tool suite or eclipse installed. If you are using plain vanilla eclipse, then M2Eclipse and EGit plugins though not required will be helpful. The maven-eclipse plugin part of pom.xml should be modified when using another IDE.

Steps

  1. git clone [email protected]:menacher/java-game-server.git
  2. cd java-game-server
  3. cd jetserver
  4. mvn eclipse:eclipse - Takes time, the first time! If you want to reduce this time, then comment out include sources/jars option from the maven pom.xml eclipse plugin part.
  5. eclipse -> file -> import -> git -> select repository and import jetserver project.
  6. jetserver project in eclipse -> right click on pom.xml -> run as -> maven test - Takes time the first time!

If everything works as expected you should see some test cases executed successfully!

With Ant

If you are using ant, then the lib folder within the jetserver project contains all the dependent libraries. Just right click and run ant build and it will create the jetserver jar.

Happy coding!

Comments
  • Refactor

    Refactor "I" from interface names

    The leading letter "I" in interfaces is really annoying when you program against interfaces, which you almost always do, when dealing with Spring Framework powered applications. I'm evaluating JetServer as a core for a game I'm planning to develop, but I'll have to fork it and refactor each I[InterfaceName] to [InterfaceName] myself and then sync changes from the original project every time a bug is fixed or an interesting feature is added. This isn't a deal-breaker of course, but a nuisance I'm not looking forward to :( I do understand that such kind of change would break the API, and I also understand that prepending or not interface names with a letter "I" is a bit holywar-ish, but I just had to try :)

    opened by AlexCzar 17
  • beans.xml parsing exception

    beans.xml parsing exception

    I run my Server from Eclipse and it works okay. Then I have create jar file using Elipse -> Create Executable Jar, Log4j configuration file is hardcoded. So this kind of error is shown

    C:\Users\Nikolay\workspace\EvolutionServer\bin>java -jar Server.jar

    main() function starts
    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefiniti
    onStoreException: Line 6 in XML document from class path resource [beans/beans.x
    ml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 6
    ; columnNumber: 120; cvc-elt.1: Cannot find the declaration of element 'beans'.
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB
    eanDefinitions(XmlBeanDefinitionReader.java:396)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
    nDefinitions(XmlBeanDefinitionReader.java:334)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBea
    nDefinitions(XmlBeanDefinitionReader.java:302)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
    r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
    r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReade
    r.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
            at org.springframework.context.annotation.ConfigurationClassBeanDefiniti
    onReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefiniti
    onReader.java:293)
            at org.springframework.context.annotation.ConfigurationClassBeanDefiniti
    onReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefiniti
    onReader.java:118)
            at org.springframework.context.annotation.ConfigurationClassBeanDefiniti
    onReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:105)
            at org.springframework.context.annotation.ConfigurationClassPostProcesso
    r.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:261)
            at org.springframework.context.annotation.ConfigurationClassPostProcesso
    r.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:178)
            at org.springframework.context.support.AbstractApplicationContext.invoke
    BeanFactoryPostProcessors(AbstractApplicationContext.java:617)
            at org.springframework.context.support.AbstractApplicationContext.refres
    h(AbstractApplicationContext.java:446)
            at org.springframework.context.annotation.AnnotationConfigApplicationCon
    text.<init>(AnnotationConfigApplicationContext.java:73)
            at org.evogame.server.Server.main(Server.java:23)
    Caused by: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 120; cvc-
    elt.1: Cannot find the declaration of element 'beans'.
            at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAX
    ParseException(ErrorHandlerWrapper.java:198)
            at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Err
    orHandlerWrapper.java:134)
            at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(
    XMLErrorReporter.java:437)
            at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(
    XMLErrorReporter.java:368)
            at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(
    XMLErrorReporter.java:325)
            at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleS
    tartElement(XMLSchemaValidator.java:1897)
            at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startEl
    ement(XMLSchemaValidator.java:737)
            at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scan
    StartElement(XMLNSDocumentScannerImpl.java:376)
            at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSCo
    ntentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:602)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
    l$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3063)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$Prolog
    Driver.next(XMLDocumentScannerImpl.java:881)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(X
    MLDocumentScannerImpl.java:607)
            at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next
    (XMLNSDocumentScannerImpl.java:116)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
    l.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
            at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
    ML11Configuration.java:835)
            at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
    ML11Configuration.java:764)
            at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.
    java:123)
            at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.
    java:240)
            at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Doc
    umentBuilderImpl.java:300)
            at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocum
    ent(DefaultDocumentLoader.java:75)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadB
    eanDefinitions(XmlBeanDefinitionReader.java:388)
    
        ... 14 more
    

    beans.xml has following contents

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <import resource="classpath:/jetserver/beans/server-beans.xml"></import>
        <context:annotation-config />
    </beans>
    
    opened by nikolaykuz 15
  • AnnotationConfigApplicationContext fails

    AnnotationConfigApplicationContext fails

    I have rebuild jetserver.jar and jetclient.jar and put new libraries in my project. Now I keep getting this error at server, so client cannot connect. My beans.xml was not updated.

    AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
    

    Can you advice what is wrong?

    2012-12-30 01:27:28,169 [SimpleSaxErrorHandler.java:47][WARN]:Ignored XML validation warning
    org.xml.sax.SAXParseException: SchemaLocation: schemaLocation value = 'http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util/spring-util-3.0.xsd' must have even number of URI's.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:423)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.storeLocations(XMLSchemaValidator.java:2365)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1776)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:711)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3104)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:921)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:232)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:255)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:196)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:181)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:239)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:196)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:181)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:293)
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:118)
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:105)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:261)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:178)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:617)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
        at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:73)
        at org.server.Server.main(Server.java:23)
    
    opened by nikolaykuz 13
  • accept or reject an user at server side

    accept or reject an user at server side

    Hello again,

    I am back to implement authentication of client at server. At client side I use this code

    Where userId, accessToken, firstName and lastName come from Facebook authentication of the client. So then client provides this data to server who will check validity of the data and then accept or the reject the user.

    public static void connect (String userId, String accessToken, String firstName, String lastName) {
            //disable previous listener
            if (future != null) {
                future.cancel();
                future.removeListener(futureListener);
            }
    
            //connect to server
            future = bootstrap.connect(new InetSocketAddress(host, port));
    
            final ChannelBuffer loginBuffer = getLoginBuffer("CONNECT_ROOM_REF_KEY", userId, accessToken, firstName, lastName);
            futureListener = new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception
                {
                    Channel channel = future.getChannel();
                    channel.write(loginBuffer);
                }
            };
    
            future.addListener(futureListener);
        }
    
        private static ChannelBuffer getLoginBuffer(String refKey, String userId, String accessToken, String firstName, String lastName) {
            //1 stands for capacity - number of bytes, big Endian
            ChannelBuffer opCode = ChannelBuffers.buffer(1);
    
            opCode.writeByte(Events.LOG_IN);
            //Creates a new composite buffer which wraps the readable bytes of the specified buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer.
            ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(opCode, NettyUtils.writeStrings(refKey, userId, accessToken, firstName, lastName));
    
            return buffer;
        }
    

    The problem is that at server side I see LOG_IN event only inside compiled library jetserver-0.1.jar.

    So how am I supposed to implement this kind of feature without touching the library?

    opened by nikolaykuz 13
  • Exception caught in class ZombieHandler java.net.SocketException: Network is unreachable

    Exception caught in class ZombieHandler java.net.SocketException: Network is unreachable

    when I excuted the main method of ZombieClient in example-games project,I got lots of exceptions like this:

    Exception caught in class ZombieHandler java.net.SocketException: Network is unreachable

    opened by jacy 11
  • How to detect client's disconnect at server and make client to connect persistently?

    How to detect client's disconnect at server and make client to connect persistently?

    I guess this solution must be straightforward, but I don't get it.

    I am using modification of Zombie example, where at Server public class SessionHandler extends DefaultSessionEventHandler implements GameCommandInterpreter

    and at Client public class ClientHandler extends SimpleChannelUpstreamHandler

    opened by nikolaykuz 10
  • Changing game room

    Changing game room

    Hi menacher,

    Thanks man for that great job you've done. But I little confused with changing room without closing current PlayerSession. How can I implement this? I tried:

            oldRoom.disconnectSession(playerSession);
            newRoom.onLogin(playerSession);
            newRoom.connectSession(playerSession);
    

    But after this I have two NetworkEventHandlers for one player session. Hence I have duplication of events processing.

    Are you sure that JetlangEventDispatcher.removeHandlersForSession works properly? I think it should be like that:

    public synchronized boolean removeHandlersForSession(Session session)
    {
        LOG.trace("Entered removeHandlersForSession for session {}", session);
        List<EventHandler> removeList = new ArrayList<EventHandler>();
    
        Collection<List<EventHandler>> eventHandlersList = new ArrayList<List<EventHandler>>(
                handlersByEventType.values());
        eventHandlersList.add(anyHandler);
    
        for (List<EventHandler> handlerList : eventHandlersList)
        {
            removeList.addAll(getHandlersToRemoveForSession(handlerList,session));
        }
    
        LOG.trace("Going to remove {} handlers for session: {}",
                removeList.size(), session);
        for (EventHandler handler : removeList)
        {
            removeHandler(handler);
        }
    
        return (removeList.size() > 0);
    }
    

    And GameRoomSession.disconnectSession should be like that:

    public synchronized boolean disconnectSession(PlayerSession playerSession)
    {
        final boolean removeHandlers = this.eventDispatcher.removeHandlersForSession(playerSession);
        return (removeHandlers & sessions.remove(playerSession));
    }
    

    For removing player session from room even if no handlers were removed.

    opened by yauhen-l 9
  • onLogin playerSession.getPlayer() is null

    onLogin playerSession.getPlayer() is null

    public class ConnectGameRoom extends GameRoomSession {

        @Override
    public void onLogin(PlayerSession playerSession)
    {
        System.out.println(playerSession.getPlayer() == null);
        }
    

    }

    prints true. Why is it so?

    opened by nikolaykuz 8
  • Null point exception in StringEncoder of Netty 3.5.1

    Null point exception in StringEncoder of Netty 3.5.1

    Netty StringEncoder:

    ... @Override protected Object encode( ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { if (!(msg instanceof String)) { return msg; } return copiedBuffer(ctx.getChannel().getConfig().getBufferFactory().getDefaultOrder(), (String) msg, charset); } ...

    NettyUtils: ChannelBuffer strBuffer = (ChannelBuffer) super.encode(null, null, msg);

    The ChannelHandlerContext can not be null.

    My version of writeString():

    public static ChannelBuffer writeString(String msg) {
        ChannelBuffer buffer = null;
        try {
            ChannelBuffer stringBuffer = ChannelBuffers.dynamicBuffer();
            stringBuffer.writeBytes(msg.getBytes(CharsetUtil.UTF_8));
            int length = stringBuffer.readableBytes();
            ChannelBuffer lengthBuffer = ChannelBuffers.buffer(2);
            lengthBuffer.writeShort(length);
            buffer = ChannelBuffers.wrappedBuffer(lengthBuffer, stringBuffer);
        } catch (Exception e) {
            LOG.error("Error occurred while trying to write string to buffer: {}", e);
        }
        return buffer;
    }
    

    OR, which version of netty does not have this problem?...

    opened by irwinmc 7
  • How to send events from player's session to game room's session?

    How to send events from player's session to game room's session?

    Hi Abraham,

    Could you please explain how to send events from player's session to game room's session? You wrote: The player session's listen on the Game Room session for any outgoing network data using event handlers. The player sessions have a reference to their Game Room using a parentGameRoom variable and can send data to it using onEvent. Do I understand correct that I have to do next steps in player's handler:

    1. Call getSession() to get player's session.
    2. Cast this session to PlayerSession.
    3. Call getParentGameRoom of this PlayerSession.
    4. Cast room to GameRoomSession.
    5. Call onEvent() of this GameRoomSession.

    I think this should be a little easier:

    1. Call getSession() to get player's session.
    2. Call onEvent() of this session.
    3. GameRoomSession catches raised event and handles it.

    In this case I have to add a custom handler to GameRoomSession.

    Perhaps such a mechanism is already provided and I'm just inattentive?

    opened by yauhen-l 7
  • room.sendBroadcast(networkEvent) is not working

    room.sendBroadcast(networkEvent) is not working

    Option 1 is not working NettyMessageBuffer outBuf = new NettyMessageBuffer(); outBuf.writeInt(GameRoomCommands.MY_EVENT.getCommand()); NetworkEvent networkEvent = Events.networkEvent(outBuf); gameRoom.sendBroadcast(networkEvent);

    Option 2 is working! NettyMessageBuffer outBuf = new NettyMessageBuffer(); outBuf.writeInt(GameRoomCommands.MY_EVENT.getCommand()); NetworkEvent networkEvent = Events.networkEvent(outBuf);

    Iterator itr = gameRoom.getSessions().iterator(); while (itr.hasNext()) { PlayerSession playerSession = (PlayerSession) itr.next(); playerSession.getTcpSender().sendMessage(networkEvent); }

    This gameRoom is not is not registered in lookupService. Initially I have only one connectGameRoom which accepts all the incoming connection. (refKeyGameRoomMap.put("CONNECT_ROOM_REF_KEY", game.getConnectGameRoom());)

    After enough players are connect, another gameRoom is created and sessions are added to it.

    opened by nikolaykuz 7
  • Could you change spring 3.x to spring 4.x

    Could you change spring 3.x to spring 4.x

    Could you change spring 3.x to spring 4.x ? I alway use jdk 8.x, so get error: Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load bean class: io.nadron.example.SpringConfig; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: class path resource [io/nadron/example/SpringConfig.class]; nested exception is java.lang.IllegalArgumentException at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:289) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461) at org.springframework.context.annotation.AnnotationConfigApplicationContext.(AnnotationConfigApplicationContext.java:73) at io.nadron.example.GameServer.main(GameServer.java:20) Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: class path resource [io/nadron/example/SpringConfig.class]; nested exception is java.lang.IllegalArgumentException at org.springframework.core.type.classreading.SimpleMetadataReader.(SimpleMetadataReader.java:56) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76) at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:298) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:231) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:154) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:140) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:282) ... 5 more Caused by: java.lang.IllegalArgumentException at org.springframework.asm.ClassReader.(Unknown Source) at org.springframework.asm.ClassReader.(Unknown Source) at org.springframework.asm.ClassReader.(Unknown Source) at org.springframework.core.type.classreading.SimpleMetadataReader.(SimpleMetadataReader.java:53) ... 13 more

    if change jdk to 1.7 or 1.6 all right. thank!

    opened by mustang2247 1
  • the wiki topic

    the wiki topic "Jetserver internal details and how it works."is too old,can you write a new version for netty version?

    i'am reading the nadron netty source code now,the only topic on wiki can help me is to old now. the topic in wiki "Jetserver internal details and how it works."is too old,can you write a new version for netty version?

    opened by jakyou 1
  • channel broadcasts error data

    channel broadcasts error data

    why this happend when i use

    for(Channel channel :channels)
    {
            channel.writeAndFlush(msg);
    }
    

    the same message send two channel had the error data it likes two channel use the same channel . are you know how it opend?

    2014-07-31 15:46:06,030 DEBUG LoggingHandler  - [id: 0x0e63b384, /192.168.1.13:52891 => /192.168.1.13:9010] RECEIVED(14B)
             +-------------------------------------------------+
             |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
    +--------+-------------------------------------------------+----------------+
    |00000000| 00 00 00 0e 00 65 00 01 00 04 63 5a 58 43       |.....e....cZXC  |
    +--------+-------------------------------------------------+----------------+
    2014-07-31 15:46:06,031 INFO  ChatMessageExecutor  - <<<<<<<<<<<<<<<<<<<<<<Name[192.168.1.15] say: cZXC>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    2014-07-31 15:46:06,032 DEBUG LoggingHandler  - [id: 0x3c51fa98, /192.168.1.13:52884 => /192.168.1.13:9010] WRITE(8B)
             +-------------------------------------------------+
             |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
    +--------+-------------------------------------------------+----------------+
    |00000000| 00 00 00 06 02 59 00 01                         |.....Y..        |
    +--------+-------------------------------------------------+----------------+
    2014-07-31 15:46:06,032 DEBUG LoggingHandler  - [id: 0x0e63b384, /192.168.1.13:52891 => /192.168.1.13:9010] WRITE(48B)
             +-------------------------------------------------+
             |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
    +--------+-------------------------------------------------+----------------+
    |00000000| 00 00 00 06 02 59 00 0c 00 00 31 39 32 2e 31 36 |.....Y....192.16|
    |00000010| 38 2e 31 2e 31 35 00 04 00 0c 58 43 00 00 31 39 |8.1.15....XC..19|
    |00000020| 32 2e 31 36 38 2e 31 2e 31 35 00 04 63 5a 58 43 |2.168.1.15..cZXC|
    +--------+-------------------------------------------------+----------------+
    2014-07-31 15:46:06,033 DEBUG LoggingHandler  - [id: 0x3c51fa98, /192.168.1.13:52884 => /192.168.1.13:9010] FLUSH
    2014-07-31 15:46:06,033 DEBUG LoggingHandler  - [id: 0x0e63b384, /192.168.1.13:52891 => /192.168.1.13:9010] FLUSH
    
    opened by Rekoe 0
Owner
Abraham Menacherry
Abraham Menacherry
A set of word-based puzzle games for the CLI while you wait for the build to run

Words Words is a set of command line word-based puzzle games. Best way to spend those minutes within the CLI while your build is running ;). But Words

Madalin Ilie 7 Sep 15, 2022
A Java Project designed to manage a football clubs players and play RNG Simulated Games against other teams.

A Java Project designed to manage a football clubs players and play RNG Simulated Games against other teams.

ztrunks 0 Feb 21, 2022
With the games: brick breakers, tic-tac-toe, snake and tetris With the apps: calculator, stopwatch and text editor Themes, and hyperlinks

Game-Launcher --------------------- ABOUT THE GAME LAUNCHER ------------------------- With the games: brick breakers, tic-tac-toe, snake and tetris Wi

João Devesa 2 Dec 26, 2021
The most powerfull forge server software (not yet) which aims for high capacity and performance on 1.16.5 modded server.

GoldenForge The most powerfull forge server software (not yet) which aims for high capacity and performance on 1.16.5 modded server. Current work Asyn

null 20 Sep 3, 2022
Othello PvP (2-Player) Game Application created in Java using Swing and AWT, for playing the Othello game

Othello PvP (2-Player) Game Application created in Java using Swing and AWT, for playing the Othello game, a simple game that played on an 8 by 8 checkered board with 64 double-sided black and white discs. The game is easy to learn, but it takes time to master and develop winning strategies.

Soumyadeep Pal 1 Feb 28, 2022
Essentials - Minecraft server command mod - Adds over 100 commands for use in-game to help manage a server

Essentials Development Readme The official repository is at: https://github.com/essentials/Essentials We use NetBeans 7.3 for development. Recommended

Essentials 811 Jan 7, 2023
A complete 3D game development suite written purely in Java.

jMonkeyEngine jMonkeyEngine is a 3-D game engine for adventurous Java developers. It’s open-source, cross-platform, and cutting-edge. 3.2.4 is the lat

jMonkeyEngine 3.3k Dec 31, 2022
A small game written in Java to review words.

这是一个实现网络连接的助记单词游戏 项目的具体功能: 实现多个用户通过网络连机进行游戏 通过对随机下落的六级词汇的补全,在游戏中提高用户的单词水平 记录每次游戏的成绩和情况(答对、答错、未答) 运用的技术及难点: 技术: 运用JavaSwing对游戏进行图形化开发,运用JavaSocket实现C/S

JavaW 2 Feb 2, 2022
A simple memory game written in java.

What's this? A simple memory game written in java. How to play Download the latest release. Ensure that a compatible java runtime is installed (optima

Patrick260 1 Jun 26, 2022
A high-level cross-platform 2D game development API

mini2Dx A high-level game development API for LibGDX inspired by Slick Website Wiki Community Javadoc Downloads Goals The main objective of mini2Dx is

null 492 Dec 24, 2022
Creates high-resolution isometric screenshots of Minecraft's game objects

Isometric Renders Overview Isometric Renders allows you to take isometric screenshots, or rather, create renders of game objects like parts of world,

glisco 74 Dec 18, 2022
BattleShip-Game - This repository contains the code of the BattleShip (Bataille Navale) game programmed in Java.

Bataille Navale Auteur : SABIL Mohamed Amine Comment générer la documentation ? Placez vous dans le sous-dossier src : pour générer la documentation d

Mohamed Amine SABIL 1 Jan 4, 2022
Golden Axe (1989) game implemented in java using only standard libraries (Java 2D, Swing, AWT & Java Sound API)

Golden Axe (1989) game implemented in java using only standard libraries (Java 2D, Swing, AWT & Java Sound API), so no external libraries required. Video: https://youtu.be/uevIVLNhQqs

Leo 101 Jul 21, 2022
A Fabric mod designed to improve server performance at high playercounts.

Very Many Players A Fabric mod designed to improve server performance at high playercounts. VMP is still in early development and things are expected

null 97 Dec 26, 2022
My Game Engine tested via my Cubecraft Game

My Game Engine tested via my Cubecraft Game Install: mvn -P {your OS name} clean install mvn -P mac clean install mvn -P linux clean install mvn -P wi

null 30 Oct 3, 2022
The game is a 2D side scrolling system, where a player moves left, right, vertically or diagonally to traverse the game.

The game is a 2D side scrolling system, where a player moves left, right, vertically or diagonally to traverse the game.

Ravi Mandal 7 Sep 11, 2022
A simple puzzle game made with Unity to practice the game engine

A simple puzzle game made with Unity to practice the game engine.

Eyüb Salih Özdemir 1 Mar 30, 2022
A basic representation of the 0-player game, "Game-of-Life", a simple example of basic cellular automata

Game-Of-Life-Basic A basic representation of the 0-player game, "Game-of-Life", a simple example of basic cellular automata. A cellular automaton is a

Nikhil Narayanan 5 Oct 27, 2022
Atomic 1.18 but it supports meteor

Atomic 1.18 but it supports meteor Downloading You can download this from releases. Download and drag into your 1.18+ mods folder to use. Important Fi

null 6 Feb 19, 2022