//
|
// Socketxxxx.h
|
// HeBeiFM
|
//
|
// Created by Apple on 16/9/22.
|
// Copyright © 2016年 Apple. All rights reserved.
|
//
|
|
#import <Foundation/Foundation.h>
|
#import "PrefixHeader.pch"
|
#import "GCDAsyncSocket.h"
|
|
#define SocketOfflineByServer @"SocketOfflineByServer"
|
|
#define SocketOfflineByUser @"SocketOfflineByUser"
|
|
#define SocketNewMessageNotification @"SocketNewMessageNotification"
|
|
#define SocketConnectErrorNotification @"SocketConnectErrorNotification"
|
#define SocketConnectSuccessNotification @"SocketConnectSuccessNotification"
|
|
typedef void(^SocketBlock)(id data);
|
|
@interface Socket : NSObject
|
@property (nonatomic, strong) GCDAsyncSocket *socket;// socket
|
@property (nonatomic, copy ) NSString *socketHost;// socket的服务器
|
@property (nonatomic, assign) UInt16 socketPort;// socket的端口
|
|
/**
|
网络情况
|
*/
|
@property (assign,nonatomic) AFNetworkReachabilityStatus netStatus;
|
|
+ (Socket *)sharedInstance;
|
|
-(void)socketConnectHost:(VoidBlock)block;// socket连接
|
|
-(void)cutOffSocket; // 断开socket连接
|
|
-(void)readData;
|
|
-(void)writeData:(NSData*)data;
|
|
|
@end
|