Sunday 24 September 2017

Socket.io: Wait for reply or handle error

Hi,my application should send some JSON to the nodeJS server and wait for the server to reply with an answer within 30 seconds.socket.emit('identifier', myJson); Either I should get a message from the nodeJS server with{'status': 'ok', 'data': { ... } } {'status': 'error', 'data': { ... } } But in case I don't get a reply within 30 seconds I want to handle it like there was an error and do what needs to be done (call methods, etc.).Emitting things and Broadcasting is not the problem I encounter, the "simple" waiting 30 seconds if there is a reply and then handling this reply or handling it as an error if there was none is the part I can't get to work.Any help is welcome. Thanks.edit: Typo

Submitted September 24, 2017 at 02:34PM by 23r01nf1n17y

No comments:

Post a Comment