📄 helloreceiptminder.java
字号:
/*JAdhoc ver 0.11 - Java AODV (RFC 3561) Protocol HandlerCopyright 2003-2004 ComNets, University of BremenThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/package jadhoc.minders;import java.net.*;import jadhoc.conf.*;import jadhoc.other.*;import jadhoc.net.*;/*** This class defines the thread that managers the lifetime of hello messages* that are received for a given route.** @author : Asanga Udugama* @date : 15-dec-2003* @email : adu@comnets.uni-bremen.de**/public class HelloReceiptMinder extends Thread { ConfigInfo cfgInfo; CurrentInfo curInfo; RouteManager rtMgr; InetAddress destIPAddr; int lifeTime; public HelloReceiptMinder(ConfigInfo cfg, CurrentInfo cur, RouteManager rm, InetAddress da, int st) { cfgInfo = cfg; curInfo = cur; rtMgr = rm; destIPAddr = da; lifeTime = st; } // in loop // sleep for lifetime given in hello expiry // then call method in route manager to check // expiry public void run() { try { // log curInfo.log.write(Logging.INFO_LOGGING, "Hello Receipt Minder - Hello Receipt Minder started for destination " + destIPAddr.getHostAddress()); // sleep for the 1st time sleep(lifeTime); while(true) { lifeTime = rtMgr.checkHelloReceived(destIPAddr, this); if(lifeTime <= 0) break; sleep(lifeTime); } // log curInfo.log.write(Logging.INFO_LOGGING, "Hello Receipt Minder - Hello Receipt Minder terminated for destination " + destIPAddr.getHostAddress()); } catch(Exception e) { // do not consider as error if the thread ended // due to the interrupt exception as this is done // purposely if(!(e instanceof InterruptedException)) { // log as error curInfo.log.write(Logging.CRITICAL_LOGGING, "Hello Receipt Minder - Hello Receipt Minder failed - " + e); } } } /** * Method to terminate the hello receipt minder */ public void terminate() { interrupt(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -