Hi, I think that Project Darkstar is an awesome tool, but I’m having a little problem with the network communication.
Sometimes when I call SimTask.sendData to send data from the server to the client, I get an exception of the following form:
WARNUNG: Exception on task execution:
target: org.akoller.sgs.textadv.Boot
method: userJoined
declared on: com.sun.gi.logic.SimUserListener
java.lang.NullPointerException
at com.sun.gi.comm.routing.impl.ChannelImpl.unicastData(ChannelImpl.java:121)
at com.sun.gi.logic.impl.SimulationImpl.sendUnicastData(SimulationImpl.java:496)
at com.sun.gi.logic.impl.DeferredUnicast.execute(SimTaskImpl.java:574)
at com.sun.gi.logic.impl.SimTaskImpl.processDeferredCommands(SimTaskImpl.java:536)
at com.sun.gi.logic.impl.SimTaskImpl.execute(SimTaskImpl.java:188)
at com.sun.gi.logic.impl.SimThreadImpl.run(SimThreadImpl.java:105)
The data the server wanted to send never arrives at the client in such a case. The exception occurs unpredictably – sometimes the data sending goes through, but rarely enough to make my game unplayable.
This already happened with the original SwordWorld system from the tutorial (after I had changed makeReference to lookupReferenceFor to get it to run). One thing that seemed to eliminate these exceptions in SwordWorld was to call openChannel(“GAMECHANNEL”) to get a new ChannelID for each call to sendData. But (a) the documentation says the lifetime of a ChannelID is from start to finish of a run of the server, so I shouldn’t need to acquire new ChannelIDs for each sendData call, and (b) it doesn’t really help after all – in my little experimental text adventure that I’ve been developing, which doesn’t do much that SwordWorld doesn’t at this point, the problem comes back even then.
The problem comes from calls to sendData, not from userJoined as the example above seems to suggest; it just occurs there because I send a welcome message to the user when they join the game.
Can you give me any advice on how to deal with this problem?