Skip to content

[Feature]: Implement real-time Notice Board updates via Socket.io#188

Open
ErebAsh wants to merge 2 commits into
Sitaram8472:mainfrom
ErebAsh:feat/realtime-notices
Open

[Feature]: Implement real-time Notice Board updates via Socket.io#188
ErebAsh wants to merge 2 commits into
Sitaram8472:mainfrom
ErebAsh:feat/realtime-notices

Conversation

@ErebAsh

@ErebAsh ErebAsh commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces real-time web socket communication for the Notice Board using socket.io. Previously, users had to manually refresh the page or rely on polling to see new announcements. With these changes, newly published notices will instantly appear for all authenticated users without requiring a page reload.

Motivation & Context

To improve the user experience for students, parents, and teachers by providing immediate, real-time awareness of important campus announcements and updates.

Key Changes

Backend:

  • Integrated socket.io to the Express server setup (server.js).
  • Implemented secure JWT authentication middleware for the socket connection to ensure only authorized users receive broadcasts.
  • Updated noticeController and teacherController to emit a newNotice event to all connected clients whenever a notice is successfully saved with a published status.

Frontend:

  • Added socket.io-client dependency.
  • Created a new socket.js utility to manage the connection instance.
  • Updated AuthContext.jsx to securely connect to the socket upon successful login (passing the JWT token) and cleanly disconnect upon logout.
  • Modified the Notices.jsx component to listen for the newNotice event and dynamically unshift new announcements into the UI state.

Checklist

  • Tested locally across different roles (Teacher -> Student).
  • Verified socket connections are authenticated via JWT.
  • Verified sockets cleanly disconnect on user logout.
  • Verified build processes run without errors.

@ErebAsh

ErebAsh commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author
Screen.Recording.2026-07-08.122454.mp4

@ErebAsh

ErebAsh commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@Sitaram8472 bro, please review and merge this pr

@Sitaram8472

Copy link
Copy Markdown
Owner

solve merge conflicts @ErebAsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Real-Time WebSockets for Notice Board

2 participants