Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.
Merged
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
1 change: 1 addition & 0 deletions ObjectiveDDP/MeteorClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef void(^MeteorClientMethodCallback)(NSDictionary *response, NSError *error
- (void)removeSubscription:(NSString *)subscriptionName;
- (void)logout;
- (void)disconnect;
- (void)ping;

// Deprecated methods

Expand Down
7 changes: 7 additions & 0 deletions ObjectiveDDP/MeteorClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ - (void)disconnect {
[self.ddp disconnectWebSocket];
}

- (void)ping {
if (!self.connected) {
return;
}
[self.ddp ping:[BSONIdGenerator generate]];
}

#pragma mark <ObjectiveDDPDelegate>

- (void)didReceiveMessage:(NSDictionary *)message {
Expand Down
1 change: 1 addition & 0 deletions ObjectiveDDP/ObjectiveDDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@property (nonatomic, assign) id <ObjectiveDDPDelegate> delegate;
@property (nonatomic, strong) SRWebSocket *webSocket;

- (void)ping:(NSString *)id;
- (void)pong:(NSString *)id;

- (id)initWithURLString:(NSString *)urlString delegate:(id <ObjectiveDDPDelegate>)delegate;
Expand Down
10 changes: 10 additions & 0 deletions ObjectiveDDP/ObjectiveDDP.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ - (void)disconnectWebSocket {
[self _closeConnection];
}

//ping (client -> server):
// id: string (the id for the ping)
- (void)ping:(NSString *)id {
NSDictionary *fields = @{@"msg": @"ping"};
if (id)
fields = @{@"msg": @"ping", @"id": id};
NSString *json = [self _buildJSONWithFields:fields parameters:nil];
[self.webSocket send:json];
}

//pong (client -> server):
// id: string (the id send with the ping)
- (void)pong:(NSString *)id {
Expand Down