Skip to content

Commit 50c06f0

Browse files
committed
Issue #37 Websocket support implemented using netty codecs and GSon.
1 parent 0d15963 commit 50c06f0

File tree

22 files changed

+830
-302
lines changed

22 files changed

+830
-302
lines changed

example-games/.classpath

Lines changed: 76 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,77 @@
1-
<classpath>
2-
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
3-
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
4-
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
5-
<classpathentry kind="output" path="target/classes"/>
6-
<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"/>
7-
<classpathentry kind="var" path="M2_REPO/org/aspectj/aspectjrt/1.6.1/aspectjrt-1.6.1.jar">
8-
<attributes>
9-
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/org/aspectj/aspectjrt/1.6.1/aspectjrt-1.6.1-javadoc.jar!/" name="javadoc_location"/>
10-
</attributes>
11-
</classpathentry>
12-
<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">
13-
<attributes>
14-
<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"/>
15-
</attributes>
16-
</classpathentry>
17-
<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"/>
18-
<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"/>
19-
<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"/>
20-
<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">
21-
<attributes>
22-
<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"/>
23-
</attributes>
24-
</classpathentry>
25-
<classpathentry kind="var" path="M2_REPO/org/menacheri/jetclient/0.1/jetclient-0.1.jar" sourcepath="M2_REPO/org/menacheri/jetclient/0.1/jetclient-0.1-sources.jar">
26-
<attributes>
27-
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/org/menacheri/jetclient/0.1/jetclient-0.1-javadoc.jar!/" name="javadoc_location"/>
28-
</attributes>
29-
</classpathentry>
30-
<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">
31-
<attributes>
32-
<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"/>
33-
</attributes>
34-
</classpathentry>
35-
<classpathentry kind="var" path="M2_REPO/org/menacheri/jetserver/0.1/jetserver-0.1.jar" sourcepath="M2_REPO/org/menacheri/jetserver/0.1/jetserver-0.1-sources.jar">
36-
<attributes>
37-
<attribute value="jar:file:/C:/Documents%20and%20Settings/abraham/.m2/repository/org/menacheri/jetserver/0.1/jetserver-0.1-javadoc.jar!/" name="javadoc_location"/>
38-
</attributes>
39-
</classpathentry>
40-
<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">
41-
<attributes>
42-
<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"/>
43-
</attributes>
44-
</classpathentry>
45-
<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">
46-
<attributes>
47-
<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"/>
48-
</attributes>
49-
</classpathentry>
50-
<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">
51-
<attributes>
52-
<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"/>
53-
</attributes>
54-
</classpathentry>
55-
<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">
56-
<attributes>
57-
<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"/>
58-
</attributes>
59-
</classpathentry>
60-
<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">
61-
<attributes>
62-
<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"/>
63-
</attributes>
64-
</classpathentry>
65-
<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"/>
66-
<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"/>
67-
<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"/>
68-
<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"/>
69-
<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"/>
70-
<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"/>
71-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
1+
<classpath>
2+
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
3+
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
4+
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
5+
<classpathentry kind="output" path="target/classes"/>
6+
<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"/>
7+
<classpathentry kind="var" path="M2_REPO/org/aspectj/aspectjrt/1.6.1/aspectjrt-1.6.1.jar">
8+
<attributes>
9+
<attribute value="jar:file:/C:/Users/aby/.m2/repository/org/aspectj/aspectjrt/1.6.1/aspectjrt-1.6.1-javadoc.jar!/" name="javadoc_location"/>
10+
</attributes>
11+
</classpathentry>
12+
<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">
13+
<attributes>
14+
<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"/>
15+
</attributes>
16+
</classpathentry>
17+
<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"/>
18+
<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"/>
19+
<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"/>
20+
<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">
21+
<attributes>
22+
<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"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.2.2/gson-2.2.2.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.2.2/gson-2.2.2-sources.jar">
26+
<attributes>
27+
<attribute value="jar:file:/C:/Users/aby/.m2/repository/com/google/code/gson/gson/2.2.2/gson-2.2.2-javadoc.jar!/" name="javadoc_location"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry kind="var" path="M2_REPO/org/menacheri/jetclient/0.1/jetclient-0.1.jar" sourcepath="M2_REPO/org/menacheri/jetclient/0.1/jetclient-0.1-sources.jar">
31+
<attributes>
32+
<attribute value="jar:file:/C:/Users/aby/.m2/repository/org/menacheri/jetclient/0.1/jetclient-0.1-javadoc.jar!/" name="javadoc_location"/>
33+
</attributes>
34+
</classpathentry>
35+
<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">
36+
<attributes>
37+
<attribute value="jar:file:/C:/Users/aby/.m2/repository/org/jetlang/jetlang/0.2.9/jetlang-0.2.9-javadoc.jar!/" name="javadoc_location"/>
38+
</attributes>
39+
</classpathentry>
40+
<classpathentry kind="var" path="M2_REPO/org/menacheri/jetserver/0.1/jetserver-0.1.jar" sourcepath="M2_REPO/org/menacheri/jetserver/0.1/jetserver-0.1-sources.jar">
41+
<attributes>
42+
<attribute value="jar:file:/C:/Users/aby/.m2/repository/org/menacheri/jetserver/0.1/jetserver-0.1-javadoc.jar!/" name="javadoc_location"/>
43+
</attributes>
44+
</classpathentry>
45+
<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">
46+
<attributes>
47+
<attribute value="jar:file:/C:/Users/aby/.m2/repository/junit/junit/4.8.2/junit-4.8.2-javadoc.jar!/" name="javadoc_location"/>
48+
</attributes>
49+
</classpathentry>
50+
<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">
51+
<attributes>
52+
<attribute value="jar:file:/C:/Users/aby/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16-javadoc.jar!/" name="javadoc_location"/>
53+
</attributes>
54+
</classpathentry>
55+
<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">
56+
<attributes>
57+
<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"/>
58+
</attributes>
59+
</classpathentry>
60+
<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">
61+
<attributes>
62+
<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"/>
63+
</attributes>
64+
</classpathentry>
65+
<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">
66+
<attributes>
67+
<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"/>
68+
</attributes>
69+
</classpathentry>
70+
<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"/>
71+
<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"/>
72+
<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"/>
73+
<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"/>
74+
<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"/>
75+
<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"/>
76+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
7277
</classpath>

example-games/.project

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<projectDescription>
2-
<name>example-games</name>
3-
<comment>This project holds some example multiplayer games that uses the jetserver library. The server part is in src/main/java and the client part of the game is in src/test/java. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
4-
<projects/>
5-
<buildSpec>
6-
<buildCommand>
7-
<name>org.eclipse.jdt.core.javabuilder</name>
8-
</buildCommand>
9-
</buildSpec>
10-
<natures>
11-
<nature>org.eclipse.jdt.core.javanature</nature>
12-
<nature>org.springframework.ide.eclipse.core.springnature</nature>
13-
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
14-
</natures>
1+
<projectDescription>
2+
<name>example-games</name>
3+
<comment>This project holds some example multiplayer games that uses the jetserver library. The server part is in src/main/java and the client part of the game is in src/test/java. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
4+
<projects/>
5+
<buildSpec>
6+
<buildCommand>
7+
<name>org.eclipse.jdt.core.javabuilder</name>
8+
</buildCommand>
9+
</buildSpec>
10+
<natures>
11+
<nature>org.eclipse.jdt.core.javanature</nature>
12+
<nature>org.springframework.ide.eclipse.core.springnature</nature>
13+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
14+
</natures>
1515
</projectDescription>
Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,59 @@
1-
package org.menacheri;
2-
3-
import java.util.concurrent.TimeUnit;
4-
5-
import org.apache.log4j.PropertyConfigurator;
6-
import org.menacheri.jetserver.app.GameRoom;
7-
import org.menacheri.jetserver.app.Task;
8-
import org.menacheri.jetserver.server.ServerManager;
9-
import org.menacheri.jetserver.service.TaskManagerService;
10-
import org.menacheri.zombie.domain.World;
11-
import org.menacheri.zombie.domain.WorldMonitor;
12-
import org.menacheri.zombie.game.ZombieRoom;
13-
import org.menacheri.zombie.game.ZombieSpringConfig;
14-
import org.slf4j.Logger;
15-
import org.slf4j.LoggerFactory;
16-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
17-
import org.springframework.context.support.AbstractApplicationContext;
18-
19-
20-
public class GameServer
21-
{
22-
private static final Logger LOG = LoggerFactory.getLogger(GameServer.class);
23-
24-
public static void main(String[] args)
25-
{
26-
PropertyConfigurator.configure(System
27-
.getProperty("log4j.configuration"));
28-
AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(ZombieSpringConfig.class);
29-
// For the destroy method to work.
30-
ctx.registerShutdownHook();
31-
32-
// Start the main game server
33-
ServerManager serverManager = ctx.getBean(ServerManager.class);
34-
//serverManager.startServers(18090,843,8081);
35-
try
36-
{
37-
serverManager.startServers();
38-
}
39-
catch (Exception e)
40-
{
41-
LOG.error("Unable to start servers cleanly: {}",e);
42-
}
43-
System.out.println("Started servers");
44-
startGames(ctx);
45-
}
46-
47-
public static void startGames(AbstractApplicationContext ctx)
48-
{
49-
World world = ctx.getBean(World.class);
50-
GameRoom room = ctx.getBean(ZombieRoom.class);
51-
Task monitor = new WorldMonitor(world,room);
52-
TaskManagerService taskManager = ctx.getBean(TaskManagerService.class);
53-
taskManager.scheduleWithFixedDelay(monitor, 500, 5000, TimeUnit.MILLISECONDS);
54-
}
55-
56-
}
1+
package org.menacheri;
2+
3+
import java.util.concurrent.TimeUnit;
4+
5+
import org.apache.log4j.PropertyConfigurator;
6+
import org.menacheri.jetserver.app.GameRoom;
7+
import org.menacheri.jetserver.app.Task;
8+
import org.menacheri.jetserver.server.ServerManager;
9+
import org.menacheri.jetserver.service.TaskManagerService;
10+
import org.menacheri.zombie.domain.World;
11+
import org.menacheri.zombie.domain.WorldMonitor;
12+
import org.menacheri.zombie.game.ZombieRoom;
13+
import org.menacheri.zombie.game.ZombieSpringConfig;
14+
import org.slf4j.Logger;
15+
import org.slf4j.LoggerFactory;
16+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
17+
import org.springframework.context.support.AbstractApplicationContext;
18+
19+
20+
public class GameServer
21+
{
22+
private static final Logger LOG = LoggerFactory.getLogger(GameServer.class);
23+
24+
public static void main(String[] args)
25+
{
26+
PropertyConfigurator.configure(System
27+
.getProperty("log4j.configuration"));
28+
AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(ZombieSpringConfig.class);
29+
// For the destroy method to work.
30+
ctx.registerShutdownHook();
31+
32+
// Start the main game server
33+
ServerManager serverManager = ctx.getBean(ServerManager.class);
34+
//serverManager.startServers(18090,843,8081);
35+
try
36+
{
37+
serverManager.startServers();
38+
}
39+
catch (Exception e)
40+
{
41+
LOG.error("Unable to start servers cleanly: {}",e);
42+
}
43+
System.out.println("Started servers");
44+
startGames(ctx);
45+
}
46+
47+
public static void startGames(AbstractApplicationContext ctx)
48+
{
49+
World world = ctx.getBean(World.class);
50+
GameRoom room1 = (GameRoom)ctx.getBean("Zombie_ROOM_1");
51+
GameRoom room2 = (GameRoom)ctx.getBean("Zombie_ROOM_2");
52+
Task monitor1 = new WorldMonitor(world,room1);
53+
Task monitor2 = new WorldMonitor(world,room2);
54+
TaskManagerService taskManager = ctx.getBean(TaskManagerService.class);
55+
taskManager.scheduleWithFixedDelay(monitor1, 1000, 5000, TimeUnit.MILLISECONDS);
56+
taskManager.scheduleWithFixedDelay(monitor2, 2000, 5000, TimeUnit.MILLISECONDS);
57+
}
58+
59+
}

0 commit comments

Comments
 (0)