|
darkfrog
|
 |
« Reply #45 on: February 14, 2006, 02:00:09 PM » |
|
how many custom listeners have you added to this API? If you disable your custom listeners does the delay stop?
darkfrog
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #46 on: February 14, 2006, 02:10:37 PM » |
|
I've removed all the listeners except for these two: (I've also included the single "processEvent" method I call on messageReceived()) client.getTCPMessageServer().addMessageListener(new MessageListener() { public void messageReceived(Message message) { } public void messageReceived(NetEvent message) { processEvent(message); } public int getListenerMode() { return MessageListener.CLOSEST; } });
client.getUDPMessageServer().addMessageListener(new MessageListener() { public void messageReceived(Message message) { } public void messageReceived(NetEvent message) { processEvent(message); } public int getListenerMode() { return MessageListener.CLOSEST; } });
private void processEvent(NetEvent event) { if (event.eventType == 99) { isConnected = true; } if (event.eventType == 100) { isConnected = true; } if (event.eventType == 8) { myplayerID = (int)(event.data[0]); } if (event.eventType == 12) { NetEvent tempevent = new NetEvent(event.sendTime,myplayerID,12,event.data); client.sendToServerUDP(tempevent); } eventq.add(event); }
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #47 on: February 14, 2006, 02:20:34 PM » |
|
I've now nanotimed my function calls from within the listeners... nothing. It's just the update() call. Also, if it helps, it wasn't happening right before the last change you made for me. 
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #48 on: February 14, 2006, 02:29:54 PM » |
|
When it was spitting out PlayerNoopMessages, how frequently was it doing so?
darkfrog
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #49 on: February 14, 2006, 02:34:59 PM » |
|
LOL! Every 8 seconds! And each time it does it, I get a pause!  Another funny thing... it sends one TCP noop, and two UDP noops (the second is one second behind the first).
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #50 on: February 14, 2006, 02:44:38 PM » |
|
Well, I still don't know why that would be causing the pause, but it would appear that it is the culprit.
I'll see what I can figure out. Also not sure why it's throwing out two UDP noops.
darkfrog
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #51 on: February 14, 2006, 03:51:27 PM » |
|
I don't know your code that well yet, but the culprit appears to be this line in the NetworkingClient file: if (getTCPMessageServer() != null) getTCPMessageServer().sendMessage(message, serverAddress, serverPortTCP); Once I commented it out, the pauses went away entirely. Of course, I'm no longer sending TCP noops either. 
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #52 on: February 14, 2006, 03:58:03 PM » |
|
I'll try to look into this tonight and see if I can resolve what is going on. Seems strange that the line you reference would take that long to execute.
darkfrog
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #53 on: February 14, 2006, 09:34:50 PM » |
|
And another question while you try to track that down... Does your current UDP implementation support NAT traversal by itself (if you don't use TCP)? I know I had some problems with that in my own code, but I was just learning NIO too.
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #54 on: February 15, 2006, 08:11:42 AM » |
|
Well, I'm not positive, but I thought that support was built into Java by default?
darkfrog
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #55 on: February 15, 2006, 08:31:28 AM » |
|
Okay, after thorough testing I cannot reproduce your issue regarding the noop sending. I don't suppose you have a thread that is looping without a sleep or yield in it do you? I actually had a problem with that in initial testing with the new TCP features. It was going extraordinarily slow and I tested everything and they were all going slower than they should be. I finally determined that it was because there was a thread running that wasn't yielding so the other threads would almost never get any cpu time.
darkfrog
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #56 on: February 15, 2006, 08:38:45 AM » |
|
I've actually gone through and checked that. I'll look into it more once I get setup for the day though. I was wondering too, what did you set Blocking too for your NIO channels?
|
|
|
|
|
Logged
|
|
|
|
|
darkfrog
|
 |
« Reply #57 on: February 15, 2006, 09:44:07 AM » |
|
blocking is set to false for TCP
darkfrog
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #58 on: February 15, 2006, 10:52:28 AM » |
|
Ok, I'm just baffled. I've tried checking and double-checking my code. I've looked over your examples in the test directory. I'm guessing I'm missing something. I tried disabling all TCP servers and clients and then things ran smoothly on just UDP (if I didn't need some TCP I'd just go that route). Or I can just comment out that line that sends a TCP noop every 9 seconds and things work fine (without noops unfortunately). I also tried my code on a Linux box, and the same thing happened. I've also tried putting the server update() into my main game loop and not running it or the network client as a thread.  I've tried switching back and forth between Thread.yield() and Thread.sleep(). I've tried threading everything out into its own thread. I'm just plum out of ideas.  Do you have any others you could share?
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #59 on: February 15, 2006, 11:09:08 AM » |
|
And after completel frustration, I found something else very interesting... When I separate the UDP and TCP noops (when I offset them so they don't happen at the same time from within the NetworkingClient code), the pause goes away.
You're not using NIO for UDP yet are you? Because if you're not, I believe your UDP method will block.
Edit: I also just tried putting the noops on separate timers (same time though, with different checks), and that seems to alleviate the problem as well.
|
|
|
|
|
Logged
|
|
|
|
|