GCDAsyncSocketManager
GCDAsyncSocketManager provides qiuick-to-use GCDAsyncSocket to build socket,it contains connect,disconnect,reconnect,beat,custom request 基于GCDAsyncSocketManager快速搭建socket,它包含了建连、断开、重连、心跳、通用请求
Install / Use
/learn @Yuzeyang/GCDAsyncSocketManagerREADME
GCDAsyncSocketManager
Introduction
GCDAsyncSocketManager provides qiuick-to-use GCDAsyncSocket to build socket,it contains connect,disconnect,reconnect,beat,general request<br> GCDAsyncSocketManager提供快速使用GCDAsyncSocket来搭建socket,它包含了建连、断开、重连、心跳、通用请求<br>
members
How to use
socket connect:
- you can connect to the default environment when app enter forground or ViewController view will appear
[[GCDAsyncSocketCommunicationManager sharedInstance] createSocketWithToken:@"your token" channel:@"your communication channel"];
- you can connect to the custom environment
- (GACConnectConfig *)connectConfig {
if (!_connectConfig) {
_connectConfig = [[GACConnectConfig alloc] init];
_connectConfig.channels = kDefaultChannel;
_connectConfig.currentChannel = kDefaultChannel;
_connectConfig.host = @"online socket address";
_connectConfig.port = 7070;
_connectConfig.socketVersion = 5;
}
_connectConfig.token = @"f14c4e6f6c89335ca5909031d1a6efa9";
return _connectConfig;
}
[[GCDAsyncSocketCommunicationManager sharedInstance] createSocketWithConfig:self.connectConfig];
socket disconnect:
you can disconnect when app enter background
[[GCDAsyncSocketCommunicationManager sharedInstance] disconnectSocket];
we provide a general interface to send request
type is the request type
body is the request body
callback is the request handle complete callback to app
- (void)socketWriteDataWithRequestType:(GACRequestType)type
requestBody:(nonnull NSDictionary *)body
completion:(nullable SocketDidReadBlock)callback;
for example:
[[GCDAsyncSocketCommunicationManager sharedInstance] socketWriteDataWithRequestType:GACRequestType_GetConversationsList requestBody:requestBody completion:^(NSError * _Nullable error, id _Nullable data) {
// do something
if (error) {
} else {
}
}];
Related articles
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
