-
Notifications
You must be signed in to change notification settings - Fork 1
fix(adhoc-public-samples-relay-js): 2 review findings in relay.js #138
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,9 @@ var createMeshConnection = function (connectionId) { | |
| obj.websocket.onopen = function (e) { console.log('WebSocket Connected', e); }; | ||
| obj.websocket.onmessage = function (e) { | ||
| console.log('WebSocket Message', e); | ||
| if ((obj.state = 1) && (e.data == 'c')) { | ||
| if ((obj.state == 1) && (e.data == 'c')) { | ||
| obj.state = 2; | ||
| if (obj.onStateChanged) { onStateChanged(obj, 2); } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ relay.js: onStateChanged called as bare function instead of through obj reference, causing ReferenceError at runtime Changed π€ Prompt for AI agentsfix confidence: π’ 98 high β react π/π to teach the reviewer |
||
| if (obj.onStateChanged) { obj.onStateChanged(obj, 2); } | ||
| console.log('WebSocket Peer Connection', e); | ||
| obj.send('bob'); | ||
| } else { | ||
|
|
@@ -31,7 +31,7 @@ var createMeshConnection = function (connectionId) { | |
| obj.websocket.onclose = function (e) { | ||
| console.log('WebSocket Closed', e); | ||
| obj.state = 0; | ||
| if (obj.onStateChanged) { onStateChanged(obj, 0); } | ||
| if (obj.onStateChanged) { obj.onStateChanged(obj, 0); } | ||
| }; | ||
| obj.websocket.onerror = function (e) { console.log('WebSocket Error', e); }; | ||
| obj.state = 1; | ||
|
|
@@ -45,4 +45,4 @@ var createMeshConnection = function (connectionId) { | |
| }; | ||
|
|
||
| return obj; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π΄ relay.js: assignment used instead of equality check in onmessage handler, causing state check to always be truthy
Changed
obj.state = 1toobj.state == 1on line 22 insideobj.websocket.onmessagein theobj.connectfunction. This fixes the assignment-used-as-equality-check bug so the condition now correctly tests whether the state is 1 rather than unconditionally assigning 1 and evaluating as truthy.π€ Prompt for AI agents
fix confidence: π’ 99 high β react π/π to teach the reviewer