Answer the question
In order to leave comments, you need to log in
There is no response from the server. Where did I go wrong (PocketSocket)?
Hello! I can not understand, I have a problem or something is wrong with the server?
// --- Connect to the service ---
// create the NSURLRequest that will be sent as the handshake
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"url"]];
// create the socket and assign delegate
self.socket = [PSWebSocket clientSocketWithRequest:request];
self.socket.delegate = self;
// open socket
[self.socket open];
#pragma mark - PSWebSocketDelegate
- (void)webSocketDidOpen:(PSWebSocket *)webSocket
{
NSLog(@"The websocket handshake completed and is now open!");
NSDictionary *send = @{@"данные"};
[webSocket send:[NSJSONSerialization dataWithJSONObject:send
options:kNilOptions
error:nil]];
}
- (void)webSocket:(PSWebSocket *)webSocket didReceiveMessage:(id)message
{
NSString *string = [[NSString alloc] initWithData:message
encoding:NSUTF8StringEncoding];
NSLog(@"The websocket received a message: %@", string);
}
- (void)webSocket:(PSWebSocket *)webSocket didFailWithError:(NSError *)error
{
NSLog(@"The websocket handshake/connection failed with an error: %@", error);
}
- (void)webSocket:(PSWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean
{
NSLog(@"The websocket closed with code: %@, reason: %@, wasClean: %@", @(code), reason, (wasClean) ? @"YES" : @"NO");
}
Answer the question
In order to leave comments, you need to log in
uh, where's the description? Describe in detail what kind of response from the socket there is in general, what methods it enters, what it writes, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question