Skip to content

foolsparadise/itdispatch_HeartBeat.iOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dispatch_HeartBeat

HeartBeat or Ping Demo for KeepAlive
心跳包或Ping的发送,每10秒发1次,流程如下
hello -> (OK,next) -> login -> (OK,next) -> heartbeat per 10 seconds
__HeartBeatSecond : 10 seconds

useage:

[[dispatch_HeartBeat shareInstance] openHeartBeat];  

or

[[dispatch_HeartBeat shareInstance] closeHeartBeat];  

when

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil];   
- (void)applicationWillEnterForeground  
{  
  [[dispatch_HeartBeat shareInstance] openHeartBeat];  
}  

and

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];  
- (void)applicationDidEnterBackground  
{  
  [[dispatch_HeartBeat shareInstance] closeHeartBeat];
}  

MIT

About

iOS心跳包或Ping的发送,代码库

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published