Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  NullPointerException in ChannelImpl.unicastData  (Read 1804 times)
0 Members and 1 Guest are viewing this topic.
Offline akoller

Junior Newbie





« Posted 2006-06-06 12:03:15 »

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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
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?
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2006-06-07 20:44:59 »

Hm.

My guess is that you are trying to send the data to the user befoer the user is joined.  Are you waiting for userJoinedChannel callback?  If so then thre may be a timign issue I need to look into.  If its timing then inserting s amll sleep before the send aught to fix it BUT thats a hack so Id like to make sure it really is a bug first...

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline akoller

Junior Newbie





« Reply #2 - Posted 2006-06-11 08:39:26 »

I just figured out what my problem probably was. I tried to send data to a null UserID. Sending to simTask.getUserID() instead seems to have fixed the issue. I still don't know why I had problems with the SwordWorld demo server, but perhaps it was something similarly trivial too.

 Embarrassed  Embarrassed  Embarrassed

I'm sorry for wasting your time with such a silly mistake. Now that I've figured out how to use a debugger on the SGS, I'm going to hunt my own bugs more thoroughly next time.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2006-06-12 21:28:53 »

Not a problem, its how we all learn.  Cool


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!