Code Monkey home page Code Monkey logo

gcdasyncsocketmanager's Introduction

GCDAsyncSocketManager

Introduction

GCDAsyncSocketManager provides qiuick-to-use GCDAsyncSocket to build socket,it contains connect,disconnect,reconnect,beat,general request
GCDAsyncSocketManager提供快速使用GCDAsyncSocket来搭建socket,它包含了建连、断开、重连、心跳、通用请求

members

Zeeyangbroccolii

How to use

socket connect:

  1. 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"];
  1. 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

iOS 基于GCDAsyncSocket快速开发Socket通信

iOS Socket重构设计

gcdasyncsocketmanager's People

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.