Skip to content

Commit

Permalink
[Sanity] Refactor
Browse files Browse the repository at this point in the history
A refactor that moves shared code and vendor code
to separate folders, and also removes code duplication
between the Mac client and the iPhone client.
This also gives a much cleaner abstraction between
code that handles view drawing and the socket
and measurment.
  • Loading branch information
sebastian committed May 18, 2012
1 parent a084f52 commit 410d9f5
Show file tree
Hide file tree
Showing 80 changed files with 791 additions and 29,168 deletions.
Expand Up @@ -42,7 +42,6 @@ typedef void(^JitterUpdatesCallback)(double, double);
}

- (id)initWithLogHandlerMessage:(LogHandler)message logHandlerError:(LogHandler)error logHandlerInfo:(LogHandler)info;

- (void)setJitterCallbackUpdate:(JitterUpdatesCallback)callback;

// Returns YES if is running as a result, and NO if it isn't.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
73 changes: 73 additions & 0 deletions SharedCode/SocketHandler.h
@@ -0,0 +1,73 @@
//
// SocketHandler.h
// SignpostDemoClient
//
// Created by Sebastian Eide on 18/05/2012.
// Copyright (c) 2012 Kle.io. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void(^ControlsToggle)(BOOL);
typedef void(^LogHandler)(NSString *);
// The block is called with jitterSeenLocally, jitterSeenByServer
typedef void(^JitterUpdatesCallback)(double, double);
// Called with downstream bandwidth, client latency, upstream bandwidth, server latency
typedef void(^GoodputLatency)(double, double, double, double);

@class GCDAsyncSocket;
@class GCDAsyncUdpSocket;
@class SharedCode;

@interface SocketHandler : NSObject
{
// Latency and goodput
dispatch_queue_t socketQueue;
GCDAsyncSocket *socket;

// Jitter
dispatch_queue_t jitterSocketQueue;
GCDAsyncUdpSocket *jitterSocket;

// General bookkeeping
BOOL isConnected;

SharedCode *commonFunc;

// For calculating jitter
NSUInteger serverJitterPort;
NSMutableArray *interarrivalTimesOfJitterMessages;
NSDate *lastReceivedMessage;

// The jitter seen by the server
double serverJitter;
NSString *serverhost;

// Goodput
double downstreamBandwidth;
double upstreamBandwidth;

// Latency
double clientLatency;
double serverLatency;

// Timers for latency and bandwidth measurements
NSDate *startTimerLatency, *startTimerBandwidth;

LogHandler callbackLogMessage;
LogHandler callbackLogError;
LogHandler callbackLogInfo;
JitterUpdatesCallback jitterUpdatesCallback;
ControlsToggle controlsToggleCallback;
GoodputLatency goodputLatencyCallback;
}

- (id)initWithLogHandlerMessage:(LogHandler)message logHandlerError:(LogHandler)error logHandlerInfo:(LogHandler)info;
- (void)setJitterCallbackUpdate:(JitterUpdatesCallback)callback;
- (void)setControlsToggleCallback:(ControlsToggle)callback;
- (void)setGoodputLatencyCallback:(GoodputLatency)callback;

- (void)startStopSocketForHost:(NSString*)host port:(NSUInteger)port;
- (void) startPingPangPongData;

@end

0 comments on commit 410d9f5

Please sign in to comment.