Kaydet (Commit) 3b097454 authored tarafından Siqi LIU's avatar Siqi LIU Kaydeden (comit) siqi

initial commit

üst deac1594
//
// Client.h
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Client : NSObject
@end
//
// Client.m
// sdremote
//
// Created by Liu Siqi on 6/3/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "Client.h"
@implementation Client
@end
......@@ -18,12 +18,14 @@
@property (nonatomic, strong) NSString* mPin;
@property (nonatomic, strong) NSString* mName;
@property int mPort;
@property const int mPort;
@property (nonatomic, weak) Server* mServer;
@property (nonatomic, weak) Receiver* mReceiver;
@property (nonatomic, weak) CommunicationManager* mComManager;
@property (nonatomic, retain) NSMutableData* mData;
@end
......@@ -36,6 +38,7 @@
@synthesize mName = _mName;
@synthesize mServer = _mServer;
@synthesize mComManager = _mComManager;
@synthesize mData = _mData;
NSString * const CHARSET = @"UTF-8";
......@@ -78,6 +81,30 @@ NSString * const CHARSET = @"UTF-8";
}
}
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
switch(eventCode) {
case NSStreamEventHasBytesAvailable:
{
if(!self.mData) {
self.mData = [NSMutableData data];
}
uint8_t buf[1024];
unsigned int len = 0;
len = [(NSInputStream *)stream read:buf maxLength:1024];
if(len) {
[self.mData appendBytes:(const void *)buf length:len];
// bytesRead is an instance variable of type NSNumber.
[bytesRead setIntValue:[bytesRead intValue]+len];
} else {
NSLog(@"no buffer!");
}
break;
}
}
}
- (void) connect
{
......
......@@ -9,5 +9,7 @@
#import <UIKit/UIKit.h>
@interface libreoffice_sdremoteViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIBarButtonItem *connect;
@end
......@@ -28,4 +28,8 @@
// Dispose of any resources that can be recreated.
}
- (void)viewDidUnload {
[self setConnect:nil];
[super viewDidUnload];
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment