Kaydet (Commit) f635e786 authored tarafından siqi's avatar siqi

comManager works now

üst b202d328
......@@ -96,6 +96,11 @@
[self.outputStream setDelegate:self];
[self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.outputStream open];
NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.name, @"\n", self.pin, @"\n\n", nil];
NSString *command = [temp componentsJoinedByString:@""];
[self sendCommand:command];
}
}
......@@ -114,18 +119,15 @@ int count = 0;
switch(eventCode) {
case NSStreamEventOpenCompleted:{
NSLog(@"Connection established");
self.connected = YES;
if (count == 1) {
[[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.connected" object:nil];
} else {
count++;
}
}
}
break;
case NSStreamEventErrorOccurred:{
NSLog(@"Connection error occured");
[self disconnect];
[[NSNotificationCenter defaultCenter]postNotificationName:@"connection.status.disconnected" object:nil];
}
break;
......@@ -153,7 +155,6 @@ int count = 0;
}
NSArray *commands = [str componentsSeparatedByString:@"\n"];
[self.receiver parse:commands];
data = nil;
str = nil;
......
......@@ -24,11 +24,7 @@
{
self = [self init];
self.client = client;
NSArray *temp = [[NSArray alloc]initWithObjects:@"LO_SERVER_CLIENT_PAIR\n", self.client.name, @"\n", self.client.pin, @"\n\n", nil];
NSString *command = [temp componentsJoinedByString:@""];
[self.client sendCommand:command];
return self;
}
......
......@@ -12,6 +12,7 @@
@class Client;
@class Server;
@class CommandInterpreter;
@class SlideShow;
#define MSG_SLIDESHOW_STARTED @"SLIDESHOW_STARTED"
#define MSG_SLIDE_CHANGED @"SLIDE_CHANGED"
......@@ -55,5 +56,6 @@ enum ConnectionState : NSInteger {
@property ConnectionState state;
@property (nonatomic, strong) id delegate;
@property (nonatomic, strong) CommandInterpreter* interpreter;
@end
......@@ -10,6 +10,7 @@
#import "CommunicationManager.h"
#import "Client.h"
#import "Server.h"
#import "SlideShow.h"
#import "CommandTransmitter.h"
#import "CommandInterpreter.h"
#import "libreoffice_sdremoteViewController.h"
......@@ -18,7 +19,6 @@
@interface CommunicationManager()
@property (nonatomic, strong) Client* client;
@property (nonatomic, strong) CommandInterpreter* interpreter;
@property (nonatomic, strong) CommandTransmitter* transmitter;
@property (atomic, strong) NSMutableSet* servers;
@property (nonatomic, strong) id connectionConnectedObserver;
......@@ -74,6 +74,7 @@
{
self = [super init];
self.state = DISCONNECTED;
self.interpreter = [[CommandInterpreter alloc] init];
[[NSNotificationCenter defaultCenter]addObserver: self
selector: @selector(connectionStatusHandler:)
......@@ -120,6 +121,7 @@
[self.client disconnect];
// initialise it with a given server
self.client = [[Client alloc]initWithServer:server managedBy:self interpretedBy:self.interpreter];
self.transmitter = [[CommandTransmitter alloc] initWithClient:self.client];
[self.client connect];
}
}
......
......@@ -15,7 +15,7 @@
@property uint size;
@property uint currentSlide;
@property (nonatomic, weak) id delegate;
@property (nonatomic, strong) id delegate;
- (void) putImage: (NSString *)img AtIndex: (uint) index;
- (void) putNotes: (NSString *)notes AtIndex: (uint) index;
......
......@@ -37,14 +37,12 @@
NSData* data = [NSData dataWithBase64String:img];
UIImage* image = [UIImage imageWithData:data];
[self.imagesArray insertObject:image atIndex:index];
slideShowViewController* vc = [self delegate];
[[vc image] setImage:image];
[[NSNotificationCenter defaultCenter] postNotificationName:@"IMAGE_READY" object:nil];
}
- (void) putNotes: (NSString *)notes AtIndex: (uint) index{
[self.notesArray insertObject:notes atIndex:index];
slideShowViewController* vc = [self delegate];
[[vc lecturer_notes] loadHTMLString:notes baseURL:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"NOTE_READY" object:nil];
}
- (UIImage *) getImageAtIndex: (uint) index
......
......@@ -12,7 +12,7 @@
<rect key="frame" x="0.0" y="64" width="768" height="960"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.40.101" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="192.168.0.22" borderStyle="roundedRect" minimumFontSize="17" id="9w1-Ym-HcF">
<rect key="frame" x="234" y="402" width="301" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
......
......@@ -11,6 +11,7 @@
#import "Server.h"
#import "slideShowViewController.h"
#import "CommunicationManager.h"
#import "CommandInterpreter.h"
@interface libreoffice_sdremoteViewController ()
......@@ -46,6 +47,7 @@
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"slidesPreviewSegue"]) {
slideShowViewController *destViewController = segue.destinationViewController;
destViewController.slideshow = [self.comManager.interpreter slideShow];
[destViewController.slideshow setDelegate:destViewController];
}
}
......
......@@ -32,20 +32,22 @@
{
[super viewDidLoad];
// NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
// NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
// [self.image setImage:[self.slideshow getImageAtIndex:0]];
// [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
// self.slideShowImageReadyObserver = [center addObserverForName:@"IMAGE_READY" object:nil
// queue:mainQueue usingBlock:^(NSNotification *note) {
// NSLog(@"Getting image to display: %@", [self.slideshow getImageAtIndex:0]);
// [self.image setImage:[self.slideshow getImageAtIndex:0]];
// }];
// self.slideShowNoteReadyObserver = [center addObserverForName:@"NOTE_READY" object:nil
// queue:mainQueue usingBlock:^(NSNotification *note) {
// NSLog(@"Getting note to display: %@", [self.slideshow getNotesAtIndex:0]);
// [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
// }]
self.slideShowImageReadyObserver = [center addObserverForName:@"IMAGE_READY" object:nil
queue:mainQueue usingBlock:^(NSNotification *note) {
if ([self.slideshow size] == 0)
NSLog(@"Oups");
NSLog(@"Getting image to display: %@", [self.slideshow getImageAtIndex:0]);
[self.image setImage:[self.slideshow getImageAtIndex:0]];
}];
self.slideShowNoteReadyObserver = [center addObserverForName:@"NOTE_READY" object:nil
queue:mainQueue usingBlock:^(NSNotification *note) {
NSLog(@"Getting note to display: %@", [self.slideshow getNotesAtIndex:0]);
[self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:0]baseURL:nil];
}];
}
......
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