Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class MyConnection : PersistentConnection
#import "SignalR.h"

//Client
SRConnection *connection = [SRConnection connectionWithURL:@"http://localhost/mysite/echo"];
SRConnection *connection = [SRConnection connectionWithURLString:@"http://localhost/mysite/echo"];

// Register for connection lifecycle events
[connection setStarted:^{
Expand Down Expand Up @@ -131,7 +131,7 @@ public class Chat : Hub
#import "SignalR.h"

// Connect to the service
SRHubConnection *hubConnection = [SRHubConnection connectionWithURL:@"http://localhost/mysite"];
SRHubConnection *hubConnection = [SRHubConnection connectionWithURLString:@"http://localhost/mysite"];
// Create a proxy to the chat service
SRHubProxy *chat = [hubConnection createHubProxy:@"chat"];
[chat on:@"addMessage" perform:self selector:@selector(addMessage:)];
Expand Down Expand Up @@ -176,7 +176,7 @@ id qs = @{
@"param1": @1,
@"param2": @"another"
};
SRConnection *connection = [SRConnection connectionWithURL:@"http://localhost/mysite" queryString:qs];
SRConnection *connection = [SRConnection connectionWithURLString:@"http://localhost/mysite" queryString:qs];
```

#### Hub Connections
Expand All @@ -185,7 +185,7 @@ id qs = @{
@"param1": @1,
@"param2": @"another"
};
SRHubConnection *hubConnection = [SRHubConnection connectionWithURL:@"http://localhost/mysite" queryString:qs];
SRHubConnection *hubConnection = [SRHubConnection connectionWithURLString:@"http://localhost/mysite" queryString:qs];
```

### Customizing Request Headers
Expand All @@ -196,11 +196,11 @@ id headers = @{
@"param1": @1,
@"param2": @"another"
};
SRConnection *connection = [SRConnection connectionWithURL:@"http://localhost/mysite"];
SRConnection *connection = [SRConnection connectionWithURLString:@"http://localhost/mysite"];
[connection setHeaders:headers];

//Alternative Usage
SRConnection *connection = [SRConnection connectionWithURL:@"http://localhost/mysite"];
SRConnection *connection = [SRConnection connectionWithURLString:@"http://localhost/mysite"];
[connection addValue:@"1" forHTTPHeaderField:@"param1"];
[connection addValue:@"another" forHTTPHeaderField:@"param2"];
```
Expand All @@ -211,11 +211,11 @@ id headers = @{
@"param1": @1,
@"param2": @"another"
};
SRHubConnection *hubConnection = [SRHubConnection connectionWithURL:@"http://localhost/mysite"];
SRHubConnection *hubConnection = [SRHubConnection connectionWithURLString:@"http://localhost/mysite"];
[hubConnection setHeaders:headers];

//Alternative Usage
SRHubConnection *hubConnection = [SRHubConnection connectionWithURL:@"http://localhost/mysite"];
SRHubConnection *hubConnection = [SRHubConnection connectionWithURLString:@"http://localhost/mysite"];
[hubConnection addValue:@"1" forHTTPHeaderField:@"param1"];
[hubConnection addValue:@"another" forHTTPHeaderField:@"param2"];
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
4 changes: 2 additions & 2 deletions SignalR.Client/Hubs/SRHubResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@property (assign, nonatomic, readwrite, getter = isHubException) BOOL hubException;

/**
* An `NSString` represnting an error received from the server
* An `NSString` representing an error received from the server
*/
@property (strong, nonatomic, readwrite) NSString *error;

Expand All @@ -52,7 +52,7 @@
@property (strong, nonatomic, readwrite) id errorData;

/**
* An `NSDictionary` represnting a server state object
* An `NSDictionary` representing a server state object
*/
@property (strong, nonatomic, readwrite) NSDictionary *state;

Expand Down
4 changes: 2 additions & 2 deletions SignalR.Client/SRConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ - (void)negotiate:(id<SRClientTransportInterface>)transport {
} else {
SRLogConnectionError(@"negotiation failed %@", error);
[strongSelf didReceiveError:error];
[strongSelf didClose];
[strongSelf stopButDoNotCallServer];
}
}];
}
Expand Down Expand Up @@ -182,7 +182,7 @@ - (void)startTransport {
} else {
SRLogConnectionError(@"start transport failed %@",error);
[strongSelf didReceiveError:error];
[strongSelf didClose];
[strongSelf stopButDoNotCallServer];
}
}];
}
Expand Down
2 changes: 1 addition & 1 deletion SignalR.Client/SRLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#define SRLogPrefixedWarn(type, frmt, ...) SRLogWarn(@"%@:\t%@", type, [NSString stringWithFormat:frmt, ##__VA_ARGS__]);
#define SRLogPrefixedInfo(type, frmt, ...) SRLogInfo(@"%@:\t%@", type, [NSString stringWithFormat:frmt, ##__VA_ARGS__]);
#define SRLogPrefixedDebug(type, frmt, ...) SRLogDebug(@"%@:\t%@", type, [NSString stringWithFormat:frmt, ##__VA_ARGS__]);
#define SRLogPrefixedVerbose(type, frmt, ...) SRLogVerboase(@"%@:\t%@", type, [NSString stringWithFormat:frmt, ##__VA_ARGS__]);
#define SRLogPrefixedVerbose(type, frmt, ...) SRLogVerbose(@"%@:\t%@", type, [NSString stringWithFormat:frmt, ##__VA_ARGS__]);

#define SRLogConnectionError(frmt, ...) SRLogPrefixedError(@"CONNECTION", frmt, ##__VA_ARGS__);
#define SRLogConnectionWarn(frmt, ...) SRLogPrefixedWarn(@"CONNECTION", frmt, ##__VA_ARGS__);
Expand Down
40 changes: 40 additions & 0 deletions Tests/Tests/SRConnectionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,44 @@ - (void) testTransportNegotiateCausesClosed
}];
}

- (void)testConnectionCanRestartAfterNegotiateError {
id failingTransport = [OCMockObject niceMockForProtocol:@protocol(SRClientTransportInterface)];
[SRMockClientTransport negotiateForMockTransport:failingTransport statusCode:@400 error:[NSError errorWithDomain:@"UNIT TEST" code:NSURLErrorTimedOut userInfo:nil]];

id successTransport = [OCMockObject niceMockForProtocol:@protocol(SRClientTransportInterface)];
[[successTransport expect] negotiate:[OCMArg any] connectionData:[OCMArg any] completionHandler:[OCMArg any]];

SRConnection* connection = [[SRConnection alloc] initWithURLString:@"http://localhost:0000"];
[connection start: failingTransport];
XCTAssertEqual(connection.state, disconnected);
[connection start: successTransport];
XCTAssertEqual(connection.state, connecting);
[successTransport verify];

}

- (void)testConnectionCanRestartAfterStartError {
id failingTransport = [OCMockObject niceMockForProtocol:@protocol(SRClientTransportInterface)];
[SRMockClientTransport startForMockTransport:failingTransport statusCode:@400 error:[[NSError alloc]initWithDomain:@"Expected" code:42 userInfo:nil]];
id json = @{
@"ConnectionId": @"10101",
@"ConnectionToken": @"10101010101",
@"DisconnectTimeout": @30,
@"ProtocolVersion": @"1.3.0.0"
};
[SRMockClientTransport negotiateForMockTransport:failingTransport statusCode:@200 json:json];

id successTransport = [OCMockObject niceMockForProtocol:@protocol(SRClientTransportInterface)];
[SRMockClientTransport negotiateForMockTransport:successTransport statusCode:@200 json:json];
[[successTransport expect] start:[OCMArg any] connectionData:[OCMArg any] completionHandler:[OCMArg any]];

SRConnection* connection = [[SRConnection alloc] initWithURLString:@"http://localhost:0000"];
[connection start: failingTransport];
XCTAssertEqual(connection.state, disconnected);
[connection start: successTransport];
XCTAssertEqual(connection.state, connecting);
[successTransport verify];

}

@end