Skip to content
Browse files

[SignpostDemo] Fix Mac UI bug plus less debug

Removed a lot of noise from the debug flow
by removing logging statements that were clogging
up the codebase.

Also fixed a bug where the socketHandler wouldn't
mark itself as being connected when it indeed was.
  • Loading branch information...
1 parent 045fa63 commit 97a07ae3a5e4e2effefbe7f61950b11cd230cead @sebastian committed May 21, 2012
View
10 SharedCode/ServerSocketHandler.m
@@ -88,7 +88,6 @@ - (BOOL)startStopSocketForPort:(NSUInteger)port andNumKBytes:(NSUInteger)numKByt
if(!isRunning)
{
// Adjust how many bytes we are going to use for the bandwidth measurements
- NSLog(@"Setting num kbytes to use to: %ld", numKBytesToUse);
if (numKBytesToUse == 0)
numKBytesToUse = 5120; // 500kbytes
[commFunc setNumberOfBytesForDataMeasurements:(numKBytesToUse * 1000)];
@@ -105,7 +104,6 @@ - (BOOL)startStopSocketForPort:(NSUInteger)port andNumKBytes:(NSUInteger)numKByt
return NO;
}
NSString *hostname = FORMAT(@"%@:%i", [listenSocket localHost], [listenSocket localPort]);
- NSLog(@"Setting hostname to: %@", hostname);
commFunc.hostname = hostname;
callbackLogInfo(FORMAT(@"Signpost demo server started on port %hu", [listenSocket localPort]));
@@ -222,7 +220,6 @@ - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
cd.startTimeLatency = startTimeLatency;
[userData setObject:cd forKey:id];
}
- NSLog(@"Sent PANG");
break;
}
case DATAFROMSERVER:
@@ -242,18 +239,15 @@ - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag
cd.startTimeBandwidth = startTimeBandwidth;
[userData setObject:cd forKey:id];
}
- NSLog(@"Sent PENG");
break;
}
case UPSTREAM_BW:
{
// Sent the upstream bandwidth data back to the client;
- NSLog(@"Sent UPSTREAM_BW");
break;
}
case SERVERJITTERPORT:
{
- NSLog(@"Sent SERVERJITTERPORT");
// We sent the client the jitter port we are listening to
break;
}
@@ -273,7 +267,6 @@ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)t
// should expect, but also send!
[sock writeData:[SharedCode intToData:[commFunc numBytesToReadForData]] withTimeout:-1 tag:PANG];
[sock readDataToData:[GCDAsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:PONG];
- NSLog(@"Received ping, wrote pang, waiting for pong");
break;
}
@@ -294,8 +287,7 @@ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)t
[sock writeData:[commFunc dataPayload] withTimeout:-1 tag:DATAFROMSERVER];
[sock readDataToData:[GCDAsyncSocket CRLFData] withTimeout:-1 tag:DOWNSTREAM_BW];
-
- NSLog(@"Received pong, sent datafromserver, waiting for downstream_bw");
+
break;
}
View
1 SharedCode/SharedCode.m
@@ -42,7 +42,6 @@ - (void)setNumberOfBytesForDataMeasurements:(NSInteger)numBytes
{
if (numBytesForData != numBytes)
{
- NSLog(@"This required a byte adjustment. The data cache is removed");
// The amount of data to send/expect has changed.
numBytesForData = numBytes;
// Reset the data payload so the right one is used the next time.
View
22 SharedCode/SocketHandler.m
@@ -79,7 +79,6 @@ - (void)startStopSocketForHost:(NSString*)host port:(NSUInteger)port
{
// Stop accepting connections
[socket disconnect];
- [jitterSocket close];
callbackLogInfo(FORMAT(@"Disconnected from %@:%i.", host, port));
controlsToggleCallback(NO);
@@ -104,7 +103,6 @@ - (void)setGoodputLatencyCallback:(GoodputLatency)callback
- (void)connectionTerminated
{
isConnected = NO;
- [jitterSocket close];
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -129,7 +127,6 @@ - (void)backgroundJitterUpdateCalculations {
{
nanosleep(&a, NULL);
double localJitter = [[commonFunc currentJitterForHost:serverhost] doubleValue];
- NSLog(@"###### UPDATING JITTER LABEL TO %f - %f", localJitter, serverJitter);
jitterUpdatesCallback(localJitter, serverJitter);
}
}
@@ -154,12 +151,14 @@ - (NSTimeInterval)socket:(GCDAsyncSocket *)sock shouldTimeoutReadWithTag:(long)t
- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err
{
+ isConnected = NO;
callbackLogInfo(FORMAT(@"Socket was closed."));
controlsToggleCallback(NO);
[self connectionTerminated];
}
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
+ isConnected = YES;
callbackLogInfo(FORMAT(@"Connected to %@:%i", host, port));
controlsToggleCallback(YES);
@@ -176,38 +175,31 @@ - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(ui
// Tell the other end that we want to start jitter measurements on the port we are listening to.
[socket writeData:[SharedCode payloadForString:hostname] withTimeout:-1 tag:CLIENTID];
[socket writeData:[SharedCode intToData:[jitterSocket localPort]] withTimeout:-1 tag:CLIENTJITTERPORT];
- NSLog(@"Write clientjitterport in didConnectToHost: %@:%i", host, port);
}
- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag {
switch (tag) {
case PING:
startTimerLatency = [commonFunc startLatencyMeasurement];
- NSLog(@"Sent ping");
break;
case PONG:
startTimerBandwidth = [commonFunc startBandwidthMeasurement];
- NSLog(@"Sent pong");
break;
case DOWNSTREAM_BW:
// We sent the downstream bandwidth number to the server
- NSLog(@"Sent downstream bandwidth");
break;
case DATAFROMCLIENT:
// We sent the data payload to measure upstream bandwidth
- NSLog(@"Sent data from client");
break;
case CLIENTID:
- NSLog(@"Sent clientId");
break;
case CLIENTJITTERPORT:
[socket readDataToData:[GCDAsyncSocket CRLFData] withTimeout:-1 tag:SERVERJITTERPORT];
- NSLog(@"Registered to read SERVERJITTERPORT after sending CLIENTJITTERPORT");
// We told the server which port we are listening on.
break;
@@ -230,8 +222,6 @@ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)t
[commonFunc setNumberOfBytesForDataMeasurements:numBytesToExpect];
[socket readDataToLength:numBytesToExpect withTimeout:READ_TIMEOUT tag:DATAFROMSERVER];
- NSLog(@"Received pang, sent pong, waiting for datafromserver");
-
callbackLogInfo(FORMAT(@"Latency: %fms", clientLatency));
break;
}
@@ -244,8 +234,6 @@ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)t
[socket writeData:data withTimeout:-1 tag:DOWNSTREAM_BW];
[socket readDataToData:[GCDAsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:PENG];
- NSLog(@"Received datafromserver, sent downstream_bw, waiting for peng");
-
callbackLogInfo(FORMAT(@"Downstream bandwidth: %f", mbitsPerSecond));
// Keep the measurement for later
@@ -261,8 +249,7 @@ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)t
serverLatency = (double) [SharedCode dataToInt:data] / 1000.0;
callbackLogInfo(FORMAT(@"Server latency: %f", serverLatency));
-
- NSLog(@"Received peng, sent datafromclient, waiting for upstrambw");
+
break;
}
@@ -271,8 +258,6 @@ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)t
NSInteger upstreamBandwidthInKbit = [SharedCode dataToInt:data];
upstreamBandwidth = (double) upstreamBandwidthInKbit / 1000.0;
callbackLogInfo(FORMAT(@"Upstream bandwidth: %f", upstreamBandwidth));
- NSLog(@"Received upstream_bw, did nothing in return");
-
goodputLatencyCallback(downstreamBandwidth, clientLatency, upstreamBandwidth, serverLatency);
// Start the next round of measurements
@@ -297,7 +282,6 @@ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)t
[commonFunc performSelectorInBackground:@selector(performJitterMeasurements:) withObject:infoDict];
dispatch_async(dispatch_get_main_queue(), ^{
- NSLog(@"#### Starting ping pang pong");
[self startPingPangPongData];
});
View
BIN SignpostDemo.xcworkspace/xcuserdata/spe24.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
View
13 SignpostDemoClient/SignpostDemoClient/AppDelegate.m
@@ -50,18 +50,19 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[socketHandler setControlsToggleCallback:^(BOOL enableControls) {
dispatch_async(dispatch_get_main_queue(), ^{
@autoreleasepool {
- [self.hostField setEnabled:enableControls];
- [self.portField setEnabled:enableControls];
- if (enableControls)
- [self.connectButton setTitle:@"Connect"];
- else
+ [self.hostField setEnabled:!enableControls];
+ [self.portField setEnabled:!enableControls];
+ if (enableControls) {
[self.connectButton setTitle:@"Disconnect"];
+ } else {
+ [self.connectButton setTitle:@"Connect"];
+ }
}
});
}];
[socketHandler setGoodputLatencyCallback:^(double downstreamBandwidth, double clientLatency, double upstreamBandwidth, double serverLatency) {
dispatch_async(dispatch_get_main_queue(), ^{
- NSLog(@"Got measurements and stuff");
+ // Nothing to do here on the client
});
}];
View
9 SignpostDemoiPhone/SignpostDemoiPhone/ViewController.m
@@ -46,23 +46,22 @@ - (void)viewDidLoad
[self addMeterAndConnectionView];
if (socketHandler == nil)
{
- NSLog(@"Setting up socket handler");
socketHandler = [[SocketHandler alloc] initWithLogHandlerMessage:^(NSString *msg) {
dispatch_async(dispatch_get_main_queue(), ^{
@autoreleasepool {
- NSLog(@"MESSAGE: %@", msg);
+ // The iPhone client does not deal with messages
}
});
} logHandlerError:^(NSString *errorStr) {
dispatch_async(dispatch_get_main_queue(), ^{
@autoreleasepool {
- NSLog(@"ERROR: %@", errorStr);
+ // The iPhone client does not currently report error messages.
}
});
} logHandlerInfo:^(NSString *infoStr) {
dispatch_async(dispatch_get_main_queue(), ^{
@autoreleasepool {
- NSLog(@"INFO: %@", infoStr);
+ // The iPhone client does not display info messages
}
});
}];
@@ -157,7 +156,6 @@ - (void)addMeterAndConnectionView
- (void)showConnectView
{
- NSLog(@"Showing connection view");
[UIView animateWithDuration:1 animations:^{
CGRect newFrame = self.connectViewControls.frame;
newFrame.origin.y = 0;
@@ -169,7 +167,6 @@ - (void)showConnectView
- (void)hideConnectView
{
- NSLog(@"Hiding connection view");
[UIView animateWithDuration:1 animations:^{
CGRect newFrame = self.connectViewControls.frame;
newFrame.origin.y = -300;

0 comments on commit 97a07ae

Please sign in to comment.
Something went wrong with that request. Please try again.