Added Web Socket inline docs#6
Conversation
| } | ||
|
|
||
| /** | ||
| * The connection function establishes a connection to the websockets |
There was a problem hiding this comment.
Suggestion: "The connect function establishes a connection to the Web socket."
| } | ||
|
|
||
| /** | ||
| * The handleMessage allows the different types of messages to be returned, stateUpdate,inventory,activity,info |
There was a problem hiding this comment.
Suggestion:
"The handleMessage function allows the different types of messages to be returned: stateUpdate, inventory, activity, and, info."
|
|
||
|
|
||
| /** | ||
| * When the connection drops or the Websocket is closed, this function will auto-retry connection until successfully connected |
There was a problem hiding this comment.
Suggestion:
If the connection drops or the Web socket unexpectedly disconnects, this function will attempt to re-establish the connection using an exponential backoff policy.
| } | ||
|
|
||
| /** | ||
| * Handles the WebSocket close event |
| } | ||
|
|
||
| /** | ||
| * Forcefully close the WebSocket, It will null the socket and stop the auto connect |
There was a problem hiding this comment.
Forcefully closes the Web socket.
Note: socket will be set to null. Auto connect will be disabled.
| * The connection function establishes a connection to the websockets | ||
| * @return {Promise<WebSocket>} | ||
| */ | ||
| connect() { |
There was a problem hiding this comment.
You are correctly guarding against the case where the API consumer calls connect when the Web socket is already connected (using this.socket.readyState !== 3) - preventing multiple connects.
What will happen if the API consumer calls connect (a second time) while the checkToken function is asynchronously fetching a new access token? In that case the socket is not technically 'connected'. It looks to me like the checkToken willl will be called again a new promise will be created?
I had something similar on iOS - let me know if the description is clear enough.
cjmconie
left a comment
There was a problem hiding this comment.
I have added a few comments, mostly around the function descriptions. Let me know they make sense.
|
Maybe the private functions should be marked with |
added inline docs for activity
No description provided.