-
Notifications
You must be signed in to change notification settings - Fork 2
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
Replace socket.io with native WebSocket communication and update dependencies #24
Conversation
Added react-use-websocket dependency and updated frontend service to handle websocket connections with authentication. Incorporated corresponding changes in the backend service to validate and respond to the authenticated requests. Also made necessary updates to frontend and backend files to support the new websocket service, and debugged new changes as well.
The code changes add a websocket functionality for when the board update mutation happens. This allows real-time updates across different users viewing the same board. Furthermore, the implementation includes a broadcast function that sends the updated board to all connected clients of the specific namespace. Additionally, a heartbeat is set up for maintaining and monitoring the connection status. A third-party library 'nanoid' has been added for generating unique client identifiers.
This commit refactors the websocket handling by removing the 'io' dependency in Board and Issue resolvers, replacing it with a more standardized 'websocketServer'. Board and Issue update methods no longer emit the old todo commented events, but instead use a 'websocketBroadcast' function to send update notifications. This function is defined in the 'ws-server.js' service. Additionally, some heartbeat and ping pong mechanisms were adjusted for better WebSocket connection stability. Also, necessary devDependencies were added in the 'package.json' file.
The code changes include removing files and code related to the socket.io library. The changes involve deleting related modules from package.json and pnpm-lock.yaml in both frontend and backend, removal of socket-related hooks and events, and removing all instances in different files where the socket was being used. The updates could be related to changes in the technical architecture or moving to a different library for websocket communication.
/describe |
PR Analysis
PR Feedback💡 General suggestions: The transition from socket.io to native WebSocket implementation is a significant change that can improve the performance and reduce the complexity of the real-time communication features of the application. It is important to ensure that the new WebSocket implementation is robust, handles reconnections gracefully, and is secure. Additionally, thorough testing should be conducted to verify that all real-time features work as expected after the transition. 🤖 Code feedback:
✨ Usage tips:
|
PR Description updated to latest commit (55fb358) |
Type
enhancement, bug_fix
Description
socket.io
implementation with native WebSocket communication in both frontend and backend.useWsAuthenticatedSocket
for frontend WebSocket communication.socket.io
client and server-side code.socket.io
and addition of WebSocket related packages.PR changes walkthrough
6 files
layout.tsx
frontend/app/layout.tsx
Removed
IoProvider
import and usage, indicating removal ofsocket.io dependency.
DropdownNotification.tsx
frontend/components/Header/DropdownNotification.tsx
Removed
useAuthenticatedSocket
and associated socket eventhandling.
index.tsx
frontend/components/Layout/index.tsx
- Added WebSocket connection status handling
**- Removed
useAuthenticatedSocket
and associated socketevent handling.
with
useWsAuthenticatedSocket
.**index.tsx
frontend/components/Notifications/index.tsx
Replaced
useAuthenticatedSocket
withuseWsAuthenticatedSocket
for WebSocket communication.useAuthenticatedSocket.tsx
frontend/hooks/useAuthenticatedSocket.tsx
Removed the entire
useAuthenticatedSocket
hook file,indicating a shift from socket.io to native WebSocket.
config.ts
frontend/services/config.ts
Changed
NEXT_PUBLIC_API_URL
to be explicitly cast as astring.
8 files
index.tsx
frontend/components/Backlog/index.tsx
- Changed
- Reorganized imports and
- Removed
- Added
**- Replaced
useAuthenticatedSocket
withuseWsAuthenticatedSocket
.PointerSensor
toMouseSensor
andTouchSensor
.components.
updateIssue
mutation usage.sendJsonMessage
call to send notifications overWebSocket.**
index.tsx
frontend/components/KanbanBoard/index.tsx
- Reorganized imports and
- Added
**- Replaced
useAuthenticatedSocket
withuseWsAuthenticatedSocket
.components.
sendJsonMessage
call to sendnotifications over WebSocket.**
useWsAuthenticatedSocket.tsx
frontend/hooks/useWsAuthenticatedSocket.tsx
Added new
useWsAuthenticatedSocket
hook for WebSocketcommunication.
socket-handlers.ts
frontend/services/socket-handlers.ts
Updated
socketMsgHandler
to handle WebSocket messages andparse them if needed.
index.js
backend/src/index.js
- Added
- Removed old socket.io event handling.**
**- Removed
fastify-socket.io
and associated setup.WebSocket server setup with authentication and heartbeat
mechanism.
index.js
backend/src/resolvers/Board/index.js
Replaced socket.io event emission with WebSocket broadcast
in
updateBoard
mutation.index.js
backend/src/resolvers/Issue/index.js
Replaced socket.io event emission with WebSocket broadcast
in
updateIssue
mutation.ws-server.js
backend/src/services/ws-server.js
Added WebSocket server utility functions for handling
connections and broadcasting messages.
4 files
package.json
backend/package.json
Removed
fastify-socket.io
andsocket.io
dependencies andadded
nanoid
andtypescript
dependencies.pnpm-lock.yaml
backend/pnpm-lock.yaml
Updated lock file with removed and added dependencies
corresponding to WebSocket changes and new packages.
package.json
frontend/package.json
Removed
socket.io-client
andsocket.io-react-hook
dependencies and added
react-use-websocket
.pnpm-lock.yaml
frontend/pnpm-lock.yaml
Updated lock file with removed and added dependencies
corresponding to WebSocket changes and new packages.