-
Notifications
You must be signed in to change notification settings - Fork 5
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
Apply socket io #122
base: main
Are you sure you want to change the base?
Apply socket io #122
Conversation
…ntment in the website the today's scheduale table updated with the new appointments
io.on('connection', (socket) => { | ||
socket.on('add appointment', (value) => { | ||
if (new Date(value).toDateString() === new Date().toDateString()) { | ||
io.sockets.emit('updateAppointments'); |
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.
why did you use io.sockets.emit while you can use io.emit directly
const io = socketIO(server); | ||
io.on('connection', (socket) => { | ||
socket.on('add appointment', (value) => { | ||
if (new Date(value).toDateString() === new Date().toDateString()) { |
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.
this condition although it is not that important here, is easy to bypass
but for other socket requests, you should make the io route to what the normal route do with the same amount of validation
@@ -4,6 +4,7 @@ import moment from 'moment'; | |||
import { useLocation } from 'react-router-dom'; | |||
import { bool } from 'prop-types'; | |||
import { message } from 'antd'; | |||
import socketIOClient from 'socket.io-client'; |
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.
repeated code
isn't it better to create a folder IO and export the functions from it
Apply socket io