Open nmolkeri opened 6 years ago
I may not have been clear last time around. I will try to make it clear as best as possible.
[socket on:@"currentAmount" callback:^(NSArray* data, SocketAckEmitter* ack) {
double cur = [[data objectAtIndex:0] floatValue];
NSLog(@"2");
[[socket emitWithAck:@"canUpdate" with:@[@(cur)]] timingOutAfter:0 callback:^(NSArray* data) {
NSLog(@"3");
[socket emit:@"update" with:@[@{@"amount": @(cur + 2.50)}]];
}];
[ack with:@[@"Got your currentAmount, ", @"dude"]];
}];
NSLog(@"4");
The sequence should be 1 2 3 4
but this socketio client doesn't wait after emitWithAck. the sequence logged is
1 2 4 3
any ideas on how to make it sequentially executed? I tried dispatching a semaphore before emitWithAck and release the semaphore when we get ack for the emitWithAck, that never helped.
I have a emit function. After the emit function is done, the socketCLeint gets back the ack and doesn't pass it to the call back immediately. It executes everything else and it NSLog's the ack as below. Is there any way I can wait until the acknowledgment is parsed and NSLoged and continue further? I tried adding a thread sleeper after emitting but it doesn't help. It sleeps for given time and executes everything and NSLogs the data below.
[[socketclient emitWithAck:type with:@[payload]] timingOutAfter:0 callback:^(NSArray* data) {NSLog(@"%@", data); }];