|
From: <sno...@us...> - 2013-09-24 03:18:16
|
Revision: 109
http://sourceforge.net/p/openrpg/svn/109
Author: snowdog_
Date: 2013-09-24 03:18:13 +0000 (Tue, 24 Sep 2013)
Log Message:
-----------
Fixed issue with NOOP message in heartbeat code.
Modified Paths:
--------------
trunk/src/openrpg2/common/core/network/NetworkServer.java
Modified: trunk/src/openrpg2/common/core/network/NetworkServer.java
===================================================================
--- trunk/src/openrpg2/common/core/network/NetworkServer.java 2013-09-23 23:42:28 UTC (rev 108)
+++ trunk/src/openrpg2/common/core/network/NetworkServer.java 2013-09-24 03:18:13 UTC (rev 109)
@@ -82,8 +82,8 @@
static final String SETTING_DEFAULT_PORT = "defaultPort";
private int threadPoolSize = DEFAULT_THREAD_POOL_SIZE;
static final int NETWORK_TIMEOUT = 300; //5 mins
- static final int NETWORK_NOOP_LIMIT = 20;//180; //3 mins
- static final int NETWORK_SWEEP_LIMIT = 10;//limit to every 10 seconds
+ static final int NETWORK_NOOP_LIMIT = 180; //3 mins
+ static final int NETWORK_SWEEP_LIMIT = 15;//limit to every 15 seconds
/**
@@ -426,29 +426,28 @@
long last = (Calendar.getInstance().getTimeInMillis() - this.lastSweep)/1000;
if( last < (long)NetworkServer.NETWORK_SWEEP_LIMIT){ return; } //not time to sweep yet, bailout
- System.out.println("Sweeping System!");
Enumeration en = clients.keys();
while(en.hasMoreElements()){
Integer i = (Integer)en.nextElement();
NetworkConnection n = (NetworkConnection)clients.get(i);
//if connection has no activity inbound for NETWORK_TIMEOUT seconds... disconnect the client.
int delta = n.stats.getInboundMessageDelta()/1000;
- System.out.println("- Client "+n.getId()+" delta: "+delta);
if( delta > NetworkServer.NETWORK_TIMEOUT){
- System.out.println("[DEBUG] SHOULD BE Disconnecting!! "+NetworkServer.NETWORK_TIMEOUT+" seconds");
- //n.disconnect();
+ log.info("Client #"+n.getId()+" has timed out. Disconnecting.");
+ n.disconnect();
}else{
if( delta >= NetworkServer.NETWORK_NOOP_LIMIT){
//fabricate a network NOOP message and push it into the send queue
- System.out.println("Sending NOOP to client "+n.getId());
ORPGMessage m = new ORPGMessage();
m.setMessageType(ORPGConstants.TYPE_NETWORK);
m.setHeader(NetworkClientModule.HEADER_OP, NetworkClientModule.OP_NOOP);
- MessageAddress ma = new MessageAddress();
- ma.append(new AddressToken(n.getId()));
- m.setDestination(ma);
- System.out.println("NOOP MESSAGE: "+m.getAsString());
+ m.setDestination(new MessageAddress(new AddressToken(n.getId())));
+ //this message does not pass through the RouteManager address checks
+ //so we have to manually set the destination array or message will not be deliverable
+ int[] dests = new int[]{n.getId()};
+ m.setFinalRecipientList(dests);
+ log.finer("Requesting heartbeat from client #"+n.getId());
sendMessage(m);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|