Multi thread safety #179
Description
First thanks for the great library.
After some digging in the code I have a question regarding thread safety. I am new to iOS so I may be mistaken here.
It seems to me that there could be races in the code between the flows that handle incoming messages and calls that the library user performs. For instance, when the user calls:
callMethodName:parameters:responseCallback
the flow eventually adds entries to _responseCallbacks (a NSMutableDictionary) and to _methodIds (a NSMutableSet). Both are used and manipulated when receiving callbacks from the SRWebSocket.
Now there is a provision for this to work correctly via [SWWebSocket setDelegateDispatchQueue] but connectWebSocket does not wait for the user to set the dispatch queue before connecting so at least the first callback might happen on the wrong dispatch queue.
Am I missing something?
Should a member be added to ObjectiveDDP that will hold the dispatch queue to use with the SRWebSocket?
Thanks,
Shai