Skip to content

Commit

Permalink
Merge pull request #48 from analog-m4/websocket-bug-fix2
Browse files Browse the repository at this point in the history
troubleshooting message received adjustment
  • Loading branch information
joh-ann authored Dec 6, 2023
2 parents ef94e25 + 6d9dbea commit 3c95e12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/components/WhiteBoard/WhiteBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@ function WhiteBoard() {
var remoteLastY = 0

function received(data) {
console.log("Receiving Message")
// console.log("Receiving Message", data)
const jsonData = JSON.parse(data.data);
const message = jsonData.message;
console.log(message)
const received_message = jsonData.message;

if (!message) {
if (!received_message) {
// console.error('Invalid data received from the server:', data);
return;
}

if (message['state'] === "start" || message['state'] === "stop") {
if (received_message['state'] === "start" || received_message['state'] === "stop") {
console.log("Info data", data)
remoteLastX = message['x'];
remoteLastY = message['y'];
remoteLastX = received_message['x'];
remoteLastY = received_message['y'];
return;
}

drawRemoteData(message['x'], message['y']);
drawRemoteData(received_message['x'], received_message['y']);
}

function drawRemoteData(x, y) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/websocket.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function createSocket() {
// const socket = new WebSocket('ws://localhost:5000/cable');
const socket = new WebSocket('wss://analog-be-18680af1ea7c.herokuapp.com/cable');
const socket = new WebSocket('ws://analog-be-18680af1ea7c.herokuapp.com/cable');
socket.onopen = function(event) {
console.log('WebSocket Client Connected');
// var id = Math.random().toString(10)
Expand Down

0 comments on commit 3c95e12

Please sign in to comment.