def notifyUser(user_id, message): """ How to use this method: from socket_events import notifyUser notifyUser(1, "sample notification message") """ new_notification = Notification(user_id, message) new_notification.save() ser_notification = NotificationSchema().dump(new_notification) socketid = online_users.get(user_id) if socketid: emit('new notification', ser_notification, room=socketid, namespace='/') return ser_notification