wxr
2020-06-16 f6fd8acd7c53c44187e70b4709443318a628f4b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
//  GlobalInfo.m
//  WiimuUPnPDemo
//
//  Created by 赵帅 on 15/1/9.
//  Copyright (c) 2015年 Wiimu. All rights reserved.
//
 
#import "GlobalInfo.h"
#import <UIKit/UIKit.h>
#import "GCDWebDAVServer.h"
 
#include <arpa/inet.h>
#import <AVFoundation/AVFoundation.h>
 
#define DEMO_PORT 22222
 
@interface GlobalInfo()
{
   GCDWebDAVServer  * httpServer;
}
 
@end
 
@implementation GlobalInfo
 
static id sharedInstance = nil;
 
+ (GlobalInfo *)sharedInstance
{
    static dispatch_once_t once;
    
    dispatch_once(&once, ^{
        sharedInstance = [[GlobalInfo alloc] init];
    });
    return sharedInstance;
}
 
- (id)init
{
    self = [super init];
    if (self) {
        [self createHTTPServer];
    }
    return self;
}
 
-(void)createHTTPServer
{
    NSString *tempDir = [self getTempPath];
    NSLog(@"tempDir is %@ ",tempDir);
    httpServer = [[GCDWebDAVServer alloc] initWithUploadDirectory:tempDir];
//    [self addGETHandlerForBasePath:@"/" directoryPath:websitePath indexFilename:nil cacheAge:3600 allowRangeRequests:YES];
 
    [httpServer startWithPort:22222 bonjourName:nil];
}
-(NSString *)getTempPath {
    NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
//    NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    return [dirs objectAtIndex:0];
}
 
@end