Comments (4)
注释里已经说非常清楚了, 因为这是单独的线程. 你需要搜索一下iOS多线程相关的资料. 简单点说, 就是要
dispatch_async(dispatch_get_main_queue()...
from icomet.
好的,感谢
from icomet.
能给个简单的事例吗,照你的方法好像不行
// this function is called in a separated thread, it gets called when receive msg from icomet server
//回调接口
size_t icomet_callback(char _ptr, size_t size, size_t nmemb, void *userdata)
{
const size_t sizeInBytes = size_nmemb;
NSData data = [[NSData alloc] initWithBytes:ptr length:sizeInBytes];
NSString s = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//开启主线程
dispatch_async(dispatch_get_main_queue(), ^
{
if([NSThread isMainThread])
{
NSLog(@"回到主线程");
}
[self setTextResult:s];//这句话说self没有定义
});
return sizeInBytes;
}
from icomet.
你好, 之前回复的方案不完整, 我已经更新了 wiki 中的示例, 你参考示例代码即可: https://github.com/ideawu/icomet/wiki/iComet-for-iOS-App
from icomet.
Related Issues (20)
- icomet研究中发现的一些问题及解决方案
- icomet 有没有生产环境中的案例
- memory leak: did not delete psub in Server::psub_end HOT 1
- 如何实现同时订阅多个频道的消息 HOT 1
- How to Enable https for icomet HOT 1
- 只要前端发起sub,就会创建channel??? HOT 1
- 手机端使用4g网络时会被"踢出"房间 HOT 1
- 希望增加POST推送消息 HOT 3
- Possible security breach
- How I can use it over https?
- 不知道为什么会出现这种情况,签名能获取到cname和token,但是sub的时候就获取不到 HOT 1
- Uncaught SyntaxError: Unexpected token : HOT 1
- 当开启Token验证的时候,如果客户端使用SSE模式订阅,无法收到错误消息
- front接口返回Content-Type不正确 HOT 1
- Recv-Q bytes not reading ... HOT 1
- 请问:生成的log是否可以按天分割 HOT 1
- 作者你好
- 有接口获取所有在线channels吗? HOT 1
- Timeout and error - 'Unexpected Identifier' HOT 3
- 作者你好
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from icomet.