sockets,包括那个用于连接voip 服务的socket。因此,当程序运行时,它需要一直从头创建socket。
- - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)connectedPort{
- [socket performBlock:^{
- [socket enableBackgroundingOnSocket];
- }];
- }
- BOOL backgroundAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];
- if (backgroundAccepted)
- {
- NSLog(@"VOIP backgrounding accepted");
- }
If
you want to let your VOIP application run in background , except those
base settings in plist file, you need a TCP socket who's property is set
to VOIP, than the iOS system will
take care this socket for you, when your application enter background ,
every thing was 'sleep' except that tcp socket. and if VOIP server send
some data thought that TCP socket, your application will be awake up
for 10 secs. during this time, you can post
a local notification.
Tcp socket can be set as VOIP Socket. But from i know , mostly VOIP
application are based on UDP socket. if you do not want to separate the
control socket from the data socket.
you should create another tcp socket which is focus on 'awake' your
application , and from my personal experience , it's very hard to keep
this 'awake' signal and the real sip control signal synchronize, the
application always miss the sip invite request.
best way is separating the sip control single from the UDP data socket ,
make it as a tcp socket , this is the best solution , but never use tcp
socket to transfer voice data.
dirty way: keep the application awake all the time. As i said , each
TCP single the application received thought that 'VOIP' tcp socket ,
will keep application awake for
10 seconds, so at the end of this duration(after 9 secs) , you can send
a response to the server to ask for another signal , when the next
signal arrived, the application will be awake again,after 9 secs , send
response again. keep doing this, your application
will awake forever.
https://github.com/robbiehanson/CocoaAsyncSocket
iOS应用中通过设置VOIP模式实现休眠状态下socket的长连接的更多相关文章
-
[转] iOS应用中通过设置VOIP模式实现休眠状态下socket的长连接
转自:http://blog.csdn.net/missautumn/article/details/17102067 如果你的应用程序需要在设备休眠的时候还能够收到服务器端发送的消息,那我们就可 ...
-
ios系统中各种设置项的url链接
ios系统中各种设置项的url链接 在代码中调用如下代码:NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];[[UIApplic ...
-
ios开发中全局变量设置和调用方法
ios开发中,全局变量设置和调用方法如下:在AppDelegate.h文件中设置全局变量:@interface ***AppDelegate{NSString *myName;}@property ( ...
-
[ios2]ios系统中各种设置项的url链接
在代码中调用如下代码:(ps: ios 5.0 以后不可用)NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];[[UIAppli ...
-
IOS 应用中从竖屏模式强制转换为横屏模式
在 iPhone 应用里,有时我们想强行把显示模式从纵屏改为横屏(反之亦然),CocoaChina 会员 “alienblue” 为我们提供了两种思路 第一种:通过人为的办法改变view.transf ...
-
[iOS] iOS系统中各种设置项的url链接
在代码中调用如下代码:NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];[[UIApplication sharedApplic ...
-
在IOS应用中从竖屏模式强制转换为横屏模式
http://www.cnblogs.com/mrhgw/archive/2012/07/18/2597218.html 在 iPhone 应用里,有时我们想强行把显示模式从纵屏改为横屏(反之亦然), ...
-
IOS中快速集成短信SDK验证开发(SMSSDK),IOS开发中如何设置手机验证码
[转载请注明出处] sdk是别人的,我只是下载来集成一下. smssdk下载网站:http://www.mob.com/(也有其他很多网站有类似SDK,譬如https://www.juhe.cn/等等 ...
-
如何在 iOS 8 中使用 Swift 实现本地通知(下)
在上集中,我们已经构建了一个简单的待办列表应用(to-do list app),这个应用可以在待办项过期时通过本地通知提醒用户.现在,我们要在之前的基础上添加以下功能:应用图标角标上显示过期待办项的数 ...
随机推荐
-
[转]Asp.net mvc 网站之速度优化 -- 页面缓存
网站速度优化的一般方法 由于网站最重要的用户体验就是速度,特别是对于电子商务网站而言. 一般网站速度优化会涉及到几个方面: 1. 数据库优化 — 查询字段简历索引,使用数据库连接池和持久化,现在还有种 ...
-
ios 关于文件操作 获取 文件大小
分类: Apple IPhone2012-06-28 11:31 4664人阅读 评论(0) 收藏 举报 ios语言manager测试c c语言 实现 #include "sys/stat ...
-
Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
-
NOI2015 Day1
NOI2015 Day1 程序自动分析 题目描述:给出等式或不等式\(n\)条,问\(n\)条式子是否成立. solution: 用并查集处理等式,在判断不等式是否成立. 时间复杂度:\(O(n)\) ...
-
BZOJ 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式( 二分答案 + 后缀数组 )
二分答案m, 后缀数组求出height数组后分组来判断. ------------------------------------------------------------ #include&l ...
-
jquery查找元素
一:查找元素 * 所有元素 element 该名称的所有元素(p,input) #id 拥有指定id属性的元素 .class 拥有所有指定class属性的元素 selector1,selector2 ...
-
vue.js 自定义事件
<div id="app"> <h2>{{num}}</h2> <h1>全局组件</h1> <my-compone ...
-
Two Sum【LeetCode】
Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...
-
DNS的过程
来自:https://www.zhihu.com/question/23042131 作者:郭无心链接:https://www.zhihu.com/question/23042131/answer/6 ...
-
java基础-day33
第10天 Transaction事务 今日内容介绍 u 事务管理 u 转账案例 u 事务总结 第1章 事务管理 1.1 事务概述 l 事务指的是逻辑上的一组操作,组成这组操作的各个单元要么全都 ...