Authored by 盖剑秋

New version of push.

Showing 45 changed files with 212 additions and 300 deletions
... ... @@ -71,7 +71,6 @@
2E7FDBCB1D5312EC005834F8 /* NSString+YOHO.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E7FDBA91D5312EC005834F8 /* NSString+YOHO.m */; };
2EA13A2A1D05733B0037C9EB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EA139F51D05733B0037C9EB /* AppDelegate.m */; };
2EA13A2B1D05733B0037C9EB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2EA139F61D05733B0037C9EB /* Assets.xcassets */; };
2EA13A2C1D05733B0037C9EB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2EA139F71D05733B0037C9EB /* LaunchScreen.storyboard */; };
2EA13A2D1D05733B0037C9EB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2EA139F91D05733B0037C9EB /* Main.storyboard */; };
2EA13A2E1D05733B0037C9EB /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 2EA139FB1D05733B0037C9EB /* Info.plist */; };
2EA13A2F1D05733B0037C9EB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EA139FC1D05733B0037C9EB /* main.m */; };
... ... @@ -292,7 +291,6 @@
2EA139F41D05733B0037C9EB /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
2EA139F51D05733B0037C9EB /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
2EA139F61D05733B0037C9EB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2EA139F81D05733B0037C9EB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2EA139FA1D05733B0037C9EB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2EA139FB1D05733B0037C9EB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2EA139FC1D05733B0037C9EB /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
... ... @@ -708,7 +706,6 @@
2EA139F41D05733B0037C9EB /* AppDelegate.h */,
2EA139F51D05733B0037C9EB /* AppDelegate.m */,
2EA139F61D05733B0037C9EB /* Assets.xcassets */,
2EA139F71D05733B0037C9EB /* LaunchScreen.storyboard */,
2EA139F91D05733B0037C9EB /* Main.storyboard */,
2EA139FB1D05733B0037C9EB /* Info.plist */,
2EA139FC1D05733B0037C9EB /* main.m */,
... ... @@ -1070,7 +1067,6 @@
2EA13A4C1D05733B0037C9EB /* portrait.png in Resources */,
2EA13A341D05733B0037C9EB /* beauty.png in Resources */,
2EA13A3E1D05733B0037C9EB /* Icon-72.png in Resources */,
2EA13A2C1D05733B0037C9EB /* LaunchScreen.storyboard in Resources */,
2EA13A551D05733B0037C9EB /* tab2.png in Resources */,
2EA13A521D05733B0037C9EB /* start.png in Resources */,
2EA13A4D1D05733B0037C9EB /* PU.png in Resources */,
... ... @@ -1262,14 +1258,6 @@
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
2EA139F71D05733B0037C9EB /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
2EA139F81D05733B0037C9EB /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
2EA139F91D05733B0037C9EB /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
... ... @@ -1330,6 +1318,7 @@
baseConfigurationReference = DF5CC49E6ACE4D402D22806C /* Pods.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_BITCODE = NO;
... ... @@ -1382,7 +1371,7 @@
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zine",
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zipzap",
);
PRODUCT_BUNDLE_IDENTIFIER = kennaki.kai.live;
PRODUCT_BUNDLE_IDENTIFIER = com.kennaki.live;
PRODUCT_NAME = YohoLive;
PROVISIONING_PROFILE = "";
USER_HEADER_SEARCH_PATHS = ./YohoLive/TXRTMPSDK.framework/Headers;
... ... @@ -1484,6 +1473,7 @@
baseConfigurationReference = DF5CC49E6ACE4D402D22806C /* Pods.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_BITCODE = NO;
... ... @@ -1532,7 +1522,7 @@
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zine",
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zipzap",
);
PRODUCT_BUNDLE_IDENTIFIER = kennaki.kai.live;
PRODUCT_BUNDLE_IDENTIFIER = com.kennaki.live;
PRODUCT_NAME = YohoLive;
PROVISIONING_PROFILE = "";
USER_HEADER_SEARCH_PATHS = ./YohoLive/TXRTMPSDK.framework/Headers;
... ... @@ -1545,6 +1535,7 @@
baseConfigurationReference = E02A0042E44F888A50E7158C /* Pods.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_BITCODE = NO;
... ... @@ -1593,7 +1584,7 @@
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zine",
"$(PROJECT_DIR)/YohoLive/yoho/Vendors/Zipzap",
);
PRODUCT_BUNDLE_IDENTIFIER = kennaki.kai.live;
PRODUCT_BUNDLE_IDENTIFIER = com.kennaki.live;
PRODUCT_NAME = YohoLive;
PROVISIONING_PROFILE = "";
USER_HEADER_SEARCH_PATHS = ./YohoLive/TXRTMPSDK.framework/Headers;
... ...
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "yohobuy_icon_29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "yohobuy_icon_58.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "yohobuy_icon_87.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "yohobuy_icon_80-1.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "yohobuy_icon_120.png",
"scale" : "3x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"size" : "60x60",
"filename" : "yohobuy_icon_57.png",
"scale" : "1x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "yohobuy_icon_114.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "yohobuy_icon_120-1.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "yohobuy_icon_180.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "yohobuy_icon_29-1.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "yohobuy_icon_58-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "yohobuy_icon_40.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "yohobuy_icon_80.png",
"scale" : "2x"
},
{
"size" : "50x50",
"idiom" : "ipad",
"filename" : "yohobuy_icon_50.png",
"scale" : "1x"
},
{
"size" : "50x50",
"idiom" : "ipad",
"size" : "40x40",
"filename" : "yohobuy_icon_100.png",
"scale" : "2x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"size" : "76x76",
"filename" : "yohobuy_icon_72.png",
"scale" : "1x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"filename" : "yohobuy_icon_144.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "yohobuy_icon_76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "yohobuy_icon_152.png",
"scale" : "2x"
},
{
... ...
... ... @@ -4,7 +4,7 @@
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "launchimage@3x.png",
"filename" : "Default-1242@3x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
... ... @@ -21,7 +21,7 @@
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "launchimage@2x.png",
"filename" : "Default-750@2x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
... ... @@ -29,7 +29,7 @@
{
"orientation" : "portrait",
"idiom" : "iphone",
"filename" : "launchimage@2x-1.png",
"filename" : "Default@2x.png",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
... ... @@ -38,7 +38,7 @@
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "launchimage@2x-4.png",
"filename" : "Default-568h@2x.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
... ... @@ -80,12 +80,14 @@
{
"orientation" : "portrait",
"idiom" : "iphone",
"filename" : "Default@2x-1.png",
"extent" : "full-screen",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"filename" : "Default-568h@2x-1.png",
"extent" : "full-screen",
"subtype" : "retina4",
"scale" : "2x"
... ...
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<imageView key="view" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launchimage1.png" id="rMv-qu-jKZ">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="launchimage1.png" width="375" height="667"/>
</resources>
</document>
... ... @@ -9,7 +9,7 @@
#import "YH_HTTPRequestOperationManager.h"
#import "AFHTTPRequestOperation.h"
#import "YH_HttpDNS.h"
#define YH_ApiHost @"http://dev-api.yohops.com:9999"
@implementation YH_HTTPRequestOperationManager
... ... @@ -20,11 +20,11 @@
NSURLRequest *resultRequest = request;
if ([[YH_HttpDNS shareInstance].dnsFlag isEqualToString:kHttpDNSOpenMD5]) {
NSString *apihost = [[NSURL URLWithString:@"http://dev-api.yohops.com:9999"] host];
NSString *apihost = [[NSURL URLWithString:YH_ApiHost] host];
if ([[request.allHTTPHeaderFields objectForKey:@"Host"] isEqualToString:apihost]
&& ![request.URL.host isEqualToString:apihost]) {
NSURL *cookieURL = [NSURL URLWithString:@"http://dev-api.yohops.com:9999"];
NSURL *cookieURL = [NSURL URLWithString:YH_ApiHost];
NSArray<NSHTTPCookie *> *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL];
NSMutableURLRequest *mutableRequest = [request mutableCopy];
[mutableRequest setAllHTTPHeaderFields:[NSHTTPCookie requestHeaderFieldsWithCookies:cookies]];
... ...
//
// YH_HTTPRequestSerializer.h
// Yohoboys
// YH_HttpRequestSerializer.h
// YH_Mall
//
// Created by redding on 14-9-18.
// Copyright (c) 2014年 YOHO. All rights reserved.
// Created by jhsonzhi on 15/8/24.
// Copyright (c) 2015年 YOHO. All rights reserved.
//
#import "AFURLRequestSerialization.h"
@interface YH_HTTPRequestSerializer : AFHTTPRequestSerializer
@interface YH_HttpRequestSerializer : AFHTTPRequestSerializer
- (instancetype)init;
@end
... ...
//
// YH_HTTPRequestSerializer.m
// Yohoboys
// YH_HttpRequestSerializer.m
// YH_Mall
//
// Created by redding on 14-9-18.
// Copyright (c) 2014年 YOHO. All rights reserved.
// Created by jhsonzhi on 15/8/24.
// Copyright (c) 2015年 YOHO. All rights reserved.
//
#import "YH_HTTPRequestSerializer.h"
#import "NSString+M16String.h"
#import "YH_HttpRequestSerializer.h"
#import <OpenUDID.h>
#import <JTSHardwareInfo.h>
#import "UtilsMacros.h"
#import <YH_Analytics.h>
#import <AdSupport/AdSupport.h>
@implementation YH_HTTPRequestSerializer
#define kScreenScale ([UIScreen instancesRespondToSelector:@selector(scale)]?[[UIScreen mainScreen] scale]:(1.0f))
#pragma mark - AFURLRequestSerialization
@implementation YH_HttpRequestSerializer
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
withParameters:(id)parameters
error:(NSError *__autoreleasing *)error
-(instancetype)init
{
NSParameterAssert(request);
if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
request = [super requestBySerializingRequest:request withParameters:nil error:error];
if (self = [super init]) {
[self setValue:[self yh_getYohoUserAgent] forHTTPHeaderField:@"User-Agent"];
}
NSMutableURLRequest *mutableRequest = [request mutableCopy];
[self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
if (![request valueForHTTPHeaderField:field]) {
[mutableRequest setValue:value forHTTPHeaderField:field];
}
}];
if (parameters) {
NSMutableDictionary *newparameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
NSString *versionstring = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
newparameters[@"curVersion"] = versionstring;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:newparameters options:(NSJSONWritingOptions)0 error:error];
NSString *query = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
query = [query encodeToPercentEscapeString];
if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
NSString *urlString = [[mutableRequest.URL absoluteString] stringByAppendingFormat:@"?parameters=%@", query];
mutableRequest.URL = [NSURL URLWithString:urlString];
} else {
if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
[mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
}
query = [NSString stringWithFormat:@"parameters=%@", query];
[mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]];
}
return self;
}
- (NSString *)yh_getYohoUserAgent
{
NSString * udidString = [OpenUDID value];
if (!udidString) {
udidString = @"";
}
return mutableRequest;
NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
long longTime = (long)time;
NSString *userAgent = [NSString stringWithFormat:@"%@/%@(Model/%@;OS/iOS%@;Scale/%0.2f;Channel/%@;Resolution/%ld*%ld;Udid/%@;sid/%@;ts/%ld;uid/%@;ifa/%@)",
[[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleNameKey],
[[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey],
[JTSHardwareInfo hardwareDisplayName],[[UIDevice currentDevice] systemVersion],kScreenScale, @"2919",(long)kScreenWidth,(long)kScreenHeight, udidString,[[YH_Analytics sharedInstance] session],longTime, @"",[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]];
return userAgent;
}
@end
... ...
... ... @@ -9,11 +9,10 @@
#import "YH_HttpEngine.h"
#import "YH_HttpDNS.h"
#import "YH_HTTPRequestOperationManager.h"
#import "YH_HttpRequestSerializer.h"
#import "YH_HTTPRequestSerializer.h"
#import "UtilsMacros.h"
#import "NSDictionary+YOHO.h"
#import "YH_Log.h"
#import "YH_HTTPRequestSerializer.h"
#import "NSString+YOHO.h"
#define YoHoErrorDomain @"YOHOErrorDomain"
... ... @@ -513,25 +512,25 @@ static NSString *const kIdentifier_live_three = @"threePicture";
+ (instancetype)validateAnchorEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/room/validmaster"];
[manager setHttpURLString:@"http://testapi.live.yohops.com:9999/v1/room/validmaster"];
return manager;
}
+ (instancetype)pushStatusEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/room/setstat"];
[manager setHttpURLString:@"http://testapi.live.yohops.com:9999/v1/room/setstat"];
return manager;
}
+ (instancetype)roomListEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/room/getpushflow"];
[manager setHttpURLString:@"http://testapi.live.yohops.com:9999/v1/room/getpushflow"];
return manager;
}
+ (instancetype)socketAddrEngine {
YH_HttpEngine *manager = [YH_HttpEngine manager];
[manager setHttpURLString:@"http://api.live.yoho.cn/v1/system/gethosts"];
[manager setHttpURLString:@"http://testapi.live.yohops.com:9999/v1/system/gethosts"];
return manager;
}
... ... @@ -674,7 +673,7 @@ static NSString *const kIdentifier_live_three = @"threePicture";
AFHTTPRequestOperationManager *manager = [YH_HTTPRequestOperationManager manager];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HTTPRequestSerializer serializer];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HttpRequestSerializer serializer];
[requestSerializer setTimeoutInterval:timeoutInterval];
[manager setRequestSerializer:requestSerializer];
... ... @@ -718,7 +717,7 @@ static NSString *const kIdentifier_live_three = @"threePicture";
NSString *url = IsStrEmpty(self.httpURLString)?YH_ServiceHost:self.httpURLString;
url = [[self checkHttpsPrefix:url] stringByAppendingString:path];
AFHTTPRequestOperationManager *manager = [YH_HTTPRequestOperationManager manager];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HTTPRequestSerializer serializer];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HttpRequestSerializer serializer];
[requestSerializer setTimeoutInterval:YHNetworkingTimeoutInterval];
[manager setRequestSerializer:requestSerializer];
... ... @@ -761,7 +760,7 @@ static NSString *const kIdentifier_live_three = @"threePicture";
NSString *url = IsStrEmpty(self.httpURLString)?YH_ServiceHost:self.httpURLString;
url = [[self checkHttpsPrefix:url] stringByAppendingString:path];
AFHTTPRequestOperationManager *manager = [YH_HTTPRequestOperationManager manager];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HTTPRequestSerializer serializer];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HttpRequestSerializer serializer];
[requestSerializer setTimeoutInterval:timeoutInterval];
[manager setRequestSerializer:requestSerializer];
... ... @@ -800,7 +799,7 @@ static NSString *const kIdentifier_live_three = @"threePicture";
AFHTTPRequestOperationManager *manager = [YH_HTTPRequestOperationManager manager];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HTTPRequestSerializer serializer];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HttpRequestSerializer serializer];
[requestSerializer setTimeoutInterval:YHNetworkingTimeoutIntervalUpload];
[manager setRequestSerializer:requestSerializer];
[manager.requestSerializer setValue:@"admin.yohobuy.com" forHTTPHeaderField:@"HTTP_REFERER"];
... ... @@ -844,7 +843,7 @@ static NSString *const kIdentifier_live_three = @"threePicture";
url = [self checkHttpsPrefix:url];
AFHTTPRequestOperationManager *manager = [YH_HTTPRequestOperationManager manager];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HTTPRequestSerializer serializer];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HttpRequestSerializer serializer];
[requestSerializer setTimeoutInterval:YHNetworkingTimeoutInterval];
[manager setRequestSerializer:requestSerializer];
... ... @@ -879,7 +878,7 @@ static NSString *const kIdentifier_live_three = @"threePicture";
url = [[self checkHttpsPrefix:url] stringByAppendingString:path];
AFHTTPRequestOperationManager *manager = [YH_HTTPRequestOperationManager manager];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HTTPRequestSerializer serializer];
AFHTTPRequestSerializer <AFURLRequestSerialization> *requestSerializer = [YH_HttpRequestSerializer serializer];
[requestSerializer setTimeoutInterval:YHNetworkingTimeoutInterval];
[manager setRequestSerializer:requestSerializer];
... ... @@ -918,7 +917,7 @@ static NSString *const kIdentifier_live_three = @"threePicture";
NSString *url = IsStrEmpty(self.httpURLString)?YH_ApiHost:self.httpURLString;
url = [self checkHttpsPrefix:url];
AFHTTPRequestOperationManager *manager = [YH_HTTPRequestOperationManager manager];
manager.requestSerializer = [YH_HTTPRequestSerializer serializer];
manager.requestSerializer = [YH_HttpRequestSerializer serializer];
// if ([YH_Global sharedInstance].securityBodyVeify) {
// [manager setResponseSerializer:[YH_HTTPResponseSerializer serializer]];
... ...
... ... @@ -100,7 +100,6 @@
@property (nonatomic, assign) BOOL loading;
@property (nonatomic, strong) GCDAsyncSocket *socket;
@property (nonatomic, assign) NSInteger currentRetryCount;
@property (nonatomic, strong) NSTimer *socketTimer;
@property (nonatomic, assign) BOOL inPushing;//是否正在直播,直播中无法切换房间以及开始新的频道直播。
... ... @@ -173,32 +172,42 @@
[self initUI];
[self loadChannelData];
[self setUpPush];
_currentRetryCount = 0;
DLog(@"=====%@",[TXLivePush getSDKVersion]);
}
- (void)continueRTMP {
if (_currentChannel) {
if ([self startRtmp]) {
[self toastTip:@"开始直播"];
_switchLock = NO;
_totalTime = _currentChannel.totalTime.integerValue;
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfoView) userInfo:nil repeats:YES];
[_timer fire];
_liveButton.selected = YES;
[self clearLog];
self.socketService.room = _currentChannel.room;
self.socketService.uid = @"";
self.socketService.userName = @"";
[self.socketService connect];
[[YH_NetworkAdapter adapter] setStatusWithStat:PushStatusStart andRoomId:_currentChannel.room completion:^(BOOL flag, NSError *error) {
if (error) {
[self toastTip:[NSString stringWithFormat:@"开始失败,原因:%@",error.localizedDescription]];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging];
}else {
if ([self startRtmp]) {
[self toastTip:@"开始直播"];
_switchLock = NO;
_totalTime = _currentChannel.totalTime.integerValue;
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfoView) userInfo:nil repeats:YES];
[_timer fire];
_liveButton.selected = YES;
[self clearLog];
self.socketService.room = _currentChannel.room;
self.socketService.uid = @"";
self.socketService.userName = @"";
[self.socketService connect];
_switchLock=NO;
} else {
[self toastTip:@"直播开始失败"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging];
}
}
[_liveButton addTarget:self action:@selector(liveButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[_liveButton setTitle:@"开始直播" forState:UIControlStateNormal];
[_liveButton setTitle:@"结束直播" forState:UIControlStateSelected];
_switchLock=NO;
}
}];
}
}
... ... @@ -256,52 +265,6 @@
}
}
}];
// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
// manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
// NSURLSessionDataTask *task= [manager
// GET:[NSString stringWithFormat:@"%@%@", API_BASE_URL_STRING, @"qcloud/getPushFlow"]
// parameters:nil progress:NULL
// success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// if ([responseObject isKindOfClass:[NSDictionary class]]) {
// id data = responseObject[@"data"];
// if (![data isKindOfClass:[NSArray class]]) {
// [self toastTip:@"没有可用直播间"];
// return;
// }
// NSMutableArray *tempAry = @[].mutableCopy;
// [data enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
// if (![obj isKindOfClass:[NSDictionary class]]) {
// *stop = YES;
// [self toastTip:@"没有可用直播间"];
// }
// YH_ChannelModel *model = [YH_ChannelModel new];
// model.roomTitle = obj[@"name"];
// model.roomURL = obj[@"url"];
// model.channel_id = obj[@"channel_id"];
// model.cid = obj[@"cid"];
// model.app = obj[@"app"];
// model.type = obj[@"type"];
// model.room = obj[@"id"];
// model.title = obj[@"title"];
// [tempAry addObject:model];
// if (_currentChannel&&[_currentChannel.roomURL isEqualToString:model.roomURL]) {
// _currentChannelIndex = idx;
// }
// }];
// _channels = [NSArray arrayWithArray:tempAry];
// [_channelTable reloadData];
// _currentChannelIndex = -1;
// }
// NSLog(@"bbbb%@",responseObject);
// _loading = NO;
// }
// failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// _loading = NO;
// [self toastTip:[NSString stringWithFormat:@"房间加载失败:%@",error.localizedDescription]];
// }];
//
// NSLog(@"%@",task.originalRequest.URL.absoluteString);
}
... ... @@ -508,13 +471,12 @@
@"videoLen":_timeLabel.text,
@"uid":@""
};
[_socket writeDataWithParams:params tag:2];
[_socket writeDataWithParams:params tag:3];
} else {
[self connectSocket];
}
}
- (void)connectSocket {
if (_socket) {
[_socket disconnect];
... ... @@ -527,20 +489,8 @@
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port
{
dispatch_async(dispatch_get_main_queue(), ^{
_currentRetryCount = 0;
DLog(@"socket connect success!");
NSDictionary *params = @{@"cmd":@(1),
@"uid":@"",
@"room":_currentChannel.room?:@"666",
@"name":@"",
@"avatar":@""
};
[_socket writeDataWithParams:params tag:1];
});
DLog(@"my socket connected....");
[self socketSendEndNotify];
}
- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err{
... ... @@ -555,11 +505,15 @@
- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
{
dispatch_async(dispatch_get_main_queue(), ^{
if (tag == 1) {//登录成功了之后才继续后面的。。。。
[self socketSendEndNotify];
if(_socketTimer == nil){
_socketTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(socketSendEndNotify) userInfo:nil repeats:YES];
}
if (tag == 1) {
NSDictionary *params = @{@"cmd":@(1),
@"uid":@"",
@"room":_currentChannel.room?:@"666",
@"name":@"",
@"avatar":@""
};
[_socket writeDataWithParams:params tag:2];
}
});
}
... ... @@ -589,28 +543,6 @@
[[YH_NetworkAdapter adapter] setStatusWithStat:PushStatusEnd andRoomId:_currentChannel.room completion:^(BOOL flag, NSError *error) {
}];
// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
// manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
// manager.requestSerializer = [YH_HTTPRequestSerializer new];
//
// NSLog(@"%@----%@",_currentChannel.room,_currentChannel.cid);
//
// NSString *temp=[NSString stringWithFormat:@"%@yohocms",_currentChannel.room?:@"0"];
// NSString *md5 = [self md5:temp];
//
// NSURLSessionDataTask *task = [manager
// GET:[NSString stringWithFormat:@"%@%@",API_BASE_URL_STRING,@"qcloud/closeLive"]
// parameters:@{@"cid":_currentChannel.room?:@"0",@"secret":md5}
// progress:NULL
// success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// NSLog(@"bbbb%@",responseObject);
// [self toastTip:responseObject[@"message"]];
// }
// failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// NSLog(@"error:%@",error.localizedDescription);
// }];
// NSLog(@"%@",task.originalRequest.URL.absoluteString);
[_socketService logout];
_socketService=nil;
});
... ... @@ -746,49 +678,6 @@
alert.tag = ValidateAlertTag;
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
// manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
// manager.requestSerializer = [YH_HTTPRequestSerializer new];
// NSString *temp=[NSString stringWithFormat:@"%@yohocms",_currentChannel.room?:@"0"];
// NSString *md5 = [self md5:temp];
// NSURLSessionDataTask *task = [manager
// GET:[NSString stringWithFormat:@"%@%@",API_BASE_URL_STRING,@"qcloud/startLive"]
// parameters:@{@"cid":_currentChannel.room?:@"0",@"secret":md5}
// progress:NULL
// success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// if ([responseObject[@"status"] isEqualToString:@"0"]) {
// if ([self startRtmp]) {
// [self toastTip:@"开始直播"];
//
//
// _totalTime = 0;
// _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfoView) userInfo:nil repeats:YES];
// [_timer fire];
// _liveButton.selected = !_liveButton.selected;
//
// [self clearLog];
//
// self.socketService.room = _currentChannel.room;
// self.socketService.uid = @"";
// self.socketService.userName = @"";
// [self.socketService connect];
//
// }else {
// [self toastTip:@"直播开始失败"];
// }
//
// }else {
// [self toastTip:responseObject[@"message"]];
// }
//
// NSLog(@"bbbb%@",responseObject);
// }
// failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
// NSLog(@"ccc");
// [self toastTip:[NSString stringWithFormat:@"开始失败,原因:%@",error.localizedDescription]];
// }];
//
// NSLog(@"%@",task.originalRequest.URL.absoluteString);
} else {
... ... @@ -827,11 +716,6 @@
[self clearLog];
self.socketService.room = _currentChannel.room;
self.socketService.uid = @"";
self.socketService.userName = @"";
[self.socketService connect];
}else {
[self toastTip:@"直播开始失败"];
}
... ...
... ... @@ -38,7 +38,6 @@
self = [super init];
if (self) {
self.socket = [[GCDAsyncSocket alloc]initWithDelegate:self delegateQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
self.heartBeatTimer = [NSTimer scheduledTimerWithTimeInterval:TimeIntervalForHeartBeat target:self selector:@selector(_heartbeat) userInfo:nil repeats:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkReachabilityDidChange:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
self.deviceToken = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970]];
}
... ... @@ -198,7 +197,13 @@
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port
{
DLog(@"socket connect success!");
[self loginToServer];
NSDictionary *params = @{@"cmd":@(14),
@"room":self.room?:@"666",
@"msg":@"",
@"uid":@""
};
[_socket writeDataWithParams:params tag:14];
self.heartBeatTimer = [NSTimer scheduledTimerWithTimeInterval:TimeIntervalForHeartBeat target:self selector:@selector(_heartbeat) userInfo:nil repeats:YES];
[self listenData];
}
... ... @@ -231,7 +236,12 @@
}
break;
case 14:
{
[self loginToServer];
}
break;
default:
break;
}
... ...
... ... @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>YOHO!推流</string>
<string>Yoho!Live</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFiles</key>
... ... @@ -27,11 +27,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>2.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>201608080001</string>
<string>201608240001</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
... ...
... ... @@ -15,7 +15,7 @@
dispatch_once(&onceToken, ^{
_sharedClient = [[M16HttpClient alloc] initWithBaseURL:[NSURL URLWithString:API_BASE_URL_STRING]];
_sharedClient.requestSerializer = [YH_HTTPRequestSerializer serializer];
_sharedClient.requestSerializer = [YH_HttpRequestSerializer serializer];
_sharedClient.responseSerializer = [YH_HTTPResponseSerializer serializer];
_sharedClient.responseSerializer.acceptableContentTypes = [_sharedClient.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
... ...
... ... @@ -10,7 +10,7 @@
@interface YH_BarrageMsgModel : M16Model
@property (nonatomic, strong) NSURL *avatar;
@property (nonatomic, strong) NSString *avatar;
@property (nonatomic, strong) NSString *userName;
@property (nonatomic, strong) NSString *uid;
@property (nonatomic, strong) NSString *message;
... ...
... ... @@ -14,7 +14,7 @@
{
self = [super init];
if (self) {
self.avatar = [NSURL URLWithString:[dictionaryValue objectForKey:@"avatar"]];
self.avatar = [dictionaryValue objectForKey:@"avatar"];
self.userName = [dictionaryValue objectForKey:@"name"];
self.uid = [dictionaryValue objectForKey:@"uid"];
self.message = [dictionaryValue objectForKey:@"msg"];
... ...
... ... @@ -7,8 +7,12 @@
//
#import "YH_BarrageMsgCell.h"
#import "YHAssistant.h"
#import "UtilsMacros.h"
#import "UIFont+LIVE.h"
#import "UIColor+YOHO.h"
#import "NSString+YOHO.h"
#import "UIImageView+WebCache.h"
#define kMsgCellDefaultHeight 60
#define kContentMarginTop 6
... ... @@ -22,6 +26,7 @@
#define kUserAvatarWidth 35
#define kUserNameLableMaxWidth (245 * kScreenPointScale - 85)
#define kUserNameLableHight 15
#define kFontUserName [UIFont fontOfLightWithSize:11]
#define kFontUserMsg [UIFont fontOfSCWithSize:13]
... ... @@ -60,7 +65,7 @@
CGSize nameSize = [nameLabelText boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size;
[self.avatarImageView setFrame:CGRectMake(-1, 0, kUserAvatarWidth, cellHeight - kContentMarginTop)];
[self.nameLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, kMarginTop, nameSize.width, nameSize.height)];
[self.nameLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, kMarginTop, nameSize.width, kUserNameLableHight)];
[self.msgLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, CGRectGetMaxY(self.nameLabel.frame)+kPandingV, msgSize.width, msgSize.height)];
CGFloat bgwidth = CGRectGetMaxX(self.msgLabel.frame) + 10;
if (nameSize.width > msgSize.width) {
... ... @@ -93,46 +98,52 @@
// CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
// _randomColor = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
NSString *colorHexStr = [self.colorArray objectAtIndex:arc4random() % [self.colorArray count]];
_randomColor = [UIColor colorWithHexString:colorHexStr];
_randomColor = [UIColor yh_colorWithHexString:colorHexStr];
}
return _randomColor;
}
//TODO
- (void)updateCellWithMessage:(YH_BarrageMsgModel *)msgModel cellWidth:(CGFloat)width
{
__weak typeof (self) weakSelf = self;
[self reLayoutCellWithWidth:width msg:msgModel];
[self.avatarImageView sd_setImageWithURL:msgModel.avatar placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[self setCornerForAvatarImageView];
NSString *avatarUrlString = [msgModel.avatar yh_splitUrlWithWidth:[NSString stringWithFormat:@"%.0lf",CGRectGetWidth(self.avatarImageView.bounds)] height:[NSString stringWithFormat:@"%.0lf",CGRectGetWidth(self.avatarImageView.bounds)]];
[self.avatarImageView sd_setImageWithURL:[NSURL URLWithString:avatarUrlString] placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
if (image) {
[weakSelf.avatarImageView setBackgroundColor:[UIColor whiteColor]];
}
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:weakSelf.avatarImageView.bounds
byRoundingCorners:(UIRectCornerBottomLeft|UIRectCornerTopLeft)
cornerRadii:CGSizeMake(6.0, 6.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = weakSelf.bgview.bounds;
maskLayer.path = maskPath.CGPath;
weakSelf.avatarImageView.layer.mask = maskLayer;
}];
[self.nameLabel setText:[NSString stringWithFormat:@"@%@", msgModel.userName]];
[self.msgLabel setText:msgModel.message];
}
- (void)setCornerForAvatarImageView {
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.avatarImageView.bounds
byRoundingCorners:(UIRectCornerBottomLeft|UIRectCornerTopLeft)
cornerRadii:CGSizeMake(6.0, 6.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bgview.bounds;
maskLayer.path = maskPath.CGPath;
self.avatarImageView.layer.mask = maskLayer;
}
+ (CGFloat)cellHeightWithMessage:(YH_BarrageMsgModel *)msgModel
{
CGFloat cellHeight = kContentMarginTop + kMarginTop + kMarginBottom + kPandingV;
cellHeight += [msgModel.userName boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size.height;
cellHeight += kUserNameLableHight;
//[msgModel.userName boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size.height;
cellHeight += [msgModel.message boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserMsg} context:nil].size.height;
... ... @@ -169,7 +180,7 @@
{
if (_nameLabel == nil) {
_nameLabel = [[UILabel alloc]init];
[_nameLabel setTextColor:[UIColor colorWithHexString:@"#B0B0B0"]];
[_nameLabel setTextColor:[UIColor yh_colorWithHexString:@"B0B0B0"]];
[_nameLabel setTextAlignment:NSTextAlignmentLeft];
[_nameLabel setFont:kFontUserName];
[_nameLabel setBackgroundColor:[UIColor clearColor]];
... ... @@ -183,7 +194,7 @@
if (_msgLabel == nil) {
_msgLabel = [[UILabel alloc]init];
[_msgLabel setNumberOfLines:0];
[_msgLabel setTextColor:[UIColor whiteColor]];
[_msgLabel setTextColor:[UIColor yh_colorWithHexString:@"FFFFFF"]];
[_msgLabel setTextAlignment:NSTextAlignmentLeft];
[_msgLabel setFont:kFontUserMsg];
[_msgLabel setBackgroundColor:[UIColor clearColor]];
... ...