[SOLVED] Multiplayer impossible !

Started by Yuri6037, June 13, 2013, 12:12:22

Previous topic - Next topic

Yuri6037

I'm trying to make a multiplayer system. I have a working server and the network interface is ok ! The only problem is when the server ask client for changing GUI, Client crashes with the knows OpenGL problem (No OpenGL context found in current thread) !
I have tried to update the network but due to a while loop when call the DataInputStream.readInt(); void, the client stuck into an interminable loop until the server is sending to client.
Now the question is :
How can i make a multiplayer game using LWJGL here is the network's interface code (client side) :

--PRIVATE--

quew8

Remember back when I showed you a message queue? Do the same thing here - add messages as the result of server action, and parse through the messages at the end of your game loop. That way all the OpenGL code gets run on the thread on which the context is current.

Yuri6037

Your solution has completely crashed NetworkInterface, OpenGL and has tried to crash my CPU by overflow !

Here is Stack Trace :
"C:\Program Files\Java\jdk1.6.0_43\bin\java" -Djava.library.path=lib\natives -Didea.launcher.port=7536 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.6.0_43\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.6.0_43\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\annotations.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\asm-commons.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\asm.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\asm4-all.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\automaton.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\boot.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\bootstrap.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\cglib-2.2.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\cli-parser-1.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\commons-codec-1.3.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\commons-httpclient-3.1-patched.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\commons-logging-1.1.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\commons-net-3.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\ecj-4.2.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\extensions.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\forms_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\groovy-all-2.0.6.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\gson-2.2.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\guava-12.0.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\icons.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\idea.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\isorelax.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\javac2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jaxen-1.1.3.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jcip-annotations.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jdkAnnotations.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jdom.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jgoodies-common-1.2.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jgoodies-forms.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jgoodies-looks-2.4.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jh.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jing.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jna-utils.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jna.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jps-server.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jsch-0.1.49.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\jsr173_1.0_api.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\junit-4.10.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\log4j.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\microba.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\miglayout-swing.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\nanoxml-2.2.3.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\nekohtml-1.9.14.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\netty-3.6.2.Final.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\openapi.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\optimizedFileManager.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\oromatcher.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\picocontainer.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\protobuf-2.4.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\proxy-vole_20120920.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\resolver.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\resources.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\resources_en.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\rhino-js-1_7R4.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\rngom-20051226-patched.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\sanselan-0.98-snapshot.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\serviceMessages.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\swingx-core-1.6.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\trang-core.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\trove4j.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\trove4j_src.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\util.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\velocity.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\winp-1.17-patched.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\xbean.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\xerces.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\xmlrpc-2.0.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\xpp3-1.1.4-min.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.1\lib\xstream-1.4.3.jar;C:\Users\Arthur\Brick Broken\Client\out\production\Client;C:\Users\Arthur\Brick Broken\Client\lib\jinput.jar;C:\Users\Arthur\Brick Broken\Client\lib\lwjgl.jar;C:\Users\Arthur\Brick Broken\Client\lib\lwjgl_util.jar;C:\Users\Arthur\Brick Broken\Client\lib\slick-util.jar;C:\Users\Arthur\Brick Broken\Client\lib\slick.jar;C:\Users\Arthur\Brick Broken\Client\lib\luaj-jse-3.0-alpha2.jar;C:\Users\Arthur\Brick Broken\Client\lib\luaj-jme-3.0-alpha2.jar" com.intellij.rt.execution.application.AppMain fr.brickbroken.client.BrickBroken
Fri Jun 14 17:00:31 CEST 2013 INFO:Slick Build #264
Fri Jun 14 17:00:31 CEST 2013 INFO:LWJGL Version: 2.9.0
Fri Jun 14 17:00:31 CEST 2013 INFO:OriginalDisplayMode: 1600 x 900 x 32 @60Hz
Fri Jun 14 17:00:31 CEST 2013 INFO:TargetDisplayMode: 1600 x 900 x 32 @60Hz
Fri Jun 14 17:00:32 CEST 2013 INFO:Starting display 1600x900
Fri Jun 14 17:00:32 CEST 2013 INFO:Use Java PNG Loader = true
WARNING: Found unknown Windows version: Windows 7
Attempting to use default windows plug-in.
Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
Fri Jun 14 17:00:33 CEST 2013 INFO:Found 1 controllers
Fri Jun 14 17:00:33 CEST 2013 INFO:0 : WingMan Force 3D
Starting...
l
lo
loc
loca
local
localh
localho
localhos
localhost
Initializing network for : Player3756772696.
Connecting to : localhost:9632
java.io.EOFException
   at java.io.DataInputStream.readInt(DataInputStream.java:375)
   at fr.brickbroken.game.ClientNetwork.updateClient(ClientNetwork.java:60)
   at fr.brickbroken.game.ClientNetwork$1.run(ClientNetwork.java:32)
Exception in thread "Thread-6" java.lang.RuntimeException: No OpenGL context found in the current thread.
   at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124)
   at org.lwjgl.opengl.GL11.glClear(GL11.java:585)
   at fr.brickbroken.game.Window.onExit(Window.java:85)
   at fr.brickbroken.client.BrickBroken.displayWindow(BrickBroken.java:141)
   at fr.brickbroken.game.ClientNetwork.updateClient(ClientNetwork.java:74)
   at fr.brickbroken.game.ClientNetwork$1.run(ClientNetwork.java:32)
java.net.SocketException: Software caused connection abort: socket write error
   at java.net.SocketOutputStream.socketWrite0(Native Method)
   at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
   at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
   at java.io.DataOutputStream.writeInt(DataOutputStream.java:181)
   at fr.brickbroken.game.ClientNetwork.sendNetPacket(ClientNetwork.java:83)
   at fr.brickbroken.game.ClientNetwork.handleInit(ClientNetwork.java:93)
   at fr.brickbroken.game.NetPacket1Init.handle(NetPacket1Init.java:25)
   at fr.brickbroken.game.ClientNetwork$2.run(ClientNetwork.java:66)
   at fr.brickbroken.client.BrickBroken.updateClientByServerInfo(BrickBroken.java:86)
   at fr.brickbroken.client.BrickBroken.update(BrickBroken.java:80)
   at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:667)
   at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361)
   at fr.brickbroken.client.BrickBroken.main(BrickBroken.java:342)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Here is new Client Network code :
--PRIVATE--

Here is the void to parse message queue (called by game update) :
--PRIVATE--

At last the call code :
--PRIVATE--

quew8

Probably you are parsing the message queue before initializing OpenGL (calling Display.create() ). Also that EOFException stands for end of file exception. It means there is also something wrong with your networking code itself.

Yuri6037

The networking system were ok before add your code !
The problem is that Client is sending in loop the first packet and don't wan't to pass !
After your solution has not corrected the OpenGL problem (No context found) !

EDIT : FIXED : Writing Error and EOF Exception !
EDIT 2 : FIXED : Context Error !
Thank you very much another time quew8 ! Multiplayer is online now ! Server accept OpenGL client now ! YYYYYYYEEEEAAAAHHH ! ! ! Light will love the game now (he wan'ts to win and me to loose !) ! Sincerly Thank you !