Skip to content

Commit 7544c43

Browse files
committed
Login and register done
1 parent a8fac94 commit 7544c43

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

votingWebSockets-Front/src/VoteApp/Pages/Votes.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21

32
export const Votes = () => {
43
return (

votingWebSockets-Front/src/VoteApp/Service/api.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ export const subscribeToVoteUpdates = (
3030
onVoteUpdate: (vote: VoteCountResponse) => void
3131
) => {
3232

33-
34-
// Establish the WebSocket connection to the server
3533
const socket = new WebSocket('wss://backend-wspq.onrender.com/ws/voting');
3634

37-
// Handle connection open event
3835
socket.onopen = () => {
3936
console.log('WebSocket connection established');
4037
};
@@ -44,7 +41,7 @@ export const subscribeToVoteUpdates = (
4441
try {
4542
const voteUpdate: VoteCountResponse = JSON.parse(event.data);
4643
console.log(voteUpdate);
47-
onVoteUpdate(voteUpdate); // Call the callback function with the received data
44+
onVoteUpdate(voteUpdate);
4845
} catch (error) {
4946
console.error('Error processing WebSocket message:', error);
5047
}
@@ -55,7 +52,6 @@ export const subscribeToVoteUpdates = (
5552
console.error('WebSocket error:', error);
5653
};
5754

58-
// Handle WebSocket connection close event
5955
socket.onclose = (event) => {
6056
if (event.wasClean) {
6157
console.log(`WebSocket connection closed cleanly, code=${event.code}, reason=${event.reason}`);
@@ -64,7 +60,6 @@ export const subscribeToVoteUpdates = (
6460
}
6561
};
6662

67-
// Return a cleanup function to close the WebSocket when it's no longer needed
6863
return () => {
6964
socket.close();
7065
};

0 commit comments

Comments
 (0)