//
|
// 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
|