RSS

(root)/iphone/common : 53 : tappity/source/TappityServer.m

To get this branch, use:
bzr branch /browse/iphone/common

« back to all changes in this revision

Viewing changes to tappity/source/TappityServer.m

Dömötör Gulyás
2009-11-06 16:51:25
Revision ID: dognotdog@gmail.com-20091106155125-ui432mcq9jgp6332
improvements on socket messenger and tappity

Show diffs side-by-side

added added

removed removed

165
165
 
166
166
        desiredFrameInterval = 0.333;
167
167
        
168
 
        receiveDataOnMainThread = YES;
 
168
        messenger = [[SocketMessenger alloc] init];
 
169
        [messenger setReceiveDataOnMainThread: YES];
 
170
        [messenger setDelegate: self];
169
171
        
170
172
        return self;
171
173
}
172
174
 
173
 
- (void) connectionWasEstablished
 
175
- (void) startBonjourServerWithName: (NSString*) name protocol: (NSString*) protocol port: (int) port
 
176
{
 
177
        [messenger startBonjourServerWithName: name protocol: protocol port: port];
 
178
}
 
179
 
 
180
- (void) connectionWasEstablished: (SocketMessenger*) theMessenger
174
181
{
175
182
        [self performSelectorOnMainThread: @selector(startScreenieTimer) withObject: nil waitUntilDone: NO];
176
183
}
184
191
        if (!capturedImagesCondition)
185
192
                capturedImagesCondition = [[NSCondition alloc] init];
186
193
 
187
 
        [self runThreadWithSelector: @selector(imageConversionThread:)];
 
194
        [messenger runThreadWithTarget: self selector: @selector(imageConversionThread:)];
188
195
}
189
196
 
190
197
/*
299
306
{
300
307
        uint32_t messageId = [[dataDict objectForKey: SocketMessageIdKey] intValue];
301
308
        
302
 
//      NSLog(@"messageid %d", messageId);
 
309
//      NSLog(@"received messageid %d", messageId);
303
310
 
304
311
        NSData* tapData = [dataDict objectForKey: SocketMessageDataKey];
305
312
        
459
466
                [self retain];
460
467
        }
461
468
 
462
 
        while ([self threadActive: info])
 
469
        while ([messenger threadActive: info])
463
470
        {
464
471
                NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
465
472
 
477
484
                NSData* imgData = UIImagePNGRepresentation(img);
478
485
        
479
486
                if (imgData)
480
 
                        [self sendData: imgData withIdentifier: kTapRawScreenshot];
 
487
                        [messenger sendData: imgData withIdentifier: kTapRawScreenshot];
481
488
 
482
489
                
483
490
                [pool drain];
485
492
        }
486
493
        
487
494
 
488
 
        [self threadWillExit: info];
 
495
        [messenger threadWillExit: info];
489
496
 
490
497
        @synchronized(self)
491
498
        {
517
524
        }
518
525
 
519
526
 
520
 
        while ([self threadActive: info])
 
527
        while ([messenger threadActive: info])
521
528
        {
522
529
                [self captureScreen];
523
530
                usleep(200);
524
531
        }
525
532
 
526
 
        [self threadWillExit: info];
 
533
        [messenger threadWillExit: info];
527
534
 
528
535
        @synchronized(self)
529
536
        {
539
546
{
540
547
        CFSwappedFloat64 sdt = CFConvertFloat64HostToSwapped(dt);
541
548
        NSData* data = [NSData dataWithBytes: &sdt length: sizeof(CFSwappedFloat64)];
542
 
        [self sendData: data withIdentifier: kTapAccelerometerUpdateInterval];
 
549
        [messenger sendData: data withIdentifier: kTapAccelerometerUpdateInterval];
543
550
}
544
551
 
545
552
/*
610
617
 
611
618
- (void) glGrabPoint
612
619
{
613
 
        if (!commsSocket || (commsSocket == -1) || !enableVisualFeedback)
 
620
        if (!enableVisualFeedback)
614
621
                return;
615
622
 
616
623
        NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
621
628
                
622
629
                NSData* data = UIImagePNGRepresentation(image);
623
630
                
624
 
                [self sendData: data withIdentifier: kTapRawScreenshot];
 
631
                [messenger sendData: data withIdentifier: kTapRawScreenshot];
625
632
                
626
633
                lastGlUpdate = now;
627
634
        }
644
651
 
645
652
- (void) dealloc
646
653
{
 
654
 
647
655
        [captureTimer invalidate];
 
656
        
 
657
        [messenger terminateConnection];
 
658
        [messenger release];
 
659
        
648
660
        [capturedImagesCondition release];
649
661
        [capturedImagesQueue release];
650
662
 

Loggerhead 1.17 is a web-based interface for Bazaar branches