Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket not parsing immediately after getting getting ack. #160

Open
nmolkeri opened this issue Feb 7, 2018 · 1 comment
Open

Socket not parsing immediately after getting getting ack. #160

nmolkeri opened this issue Feb 7, 2018 · 1 comment

Comments

@nmolkeri
Copy link

nmolkeri commented Feb 7, 2018

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); }];

@nmolkeri
Copy link
Author

nmolkeri commented Feb 23, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant