I have a functionality where I need to remind the customers about their appointments before the time interval set while creating the appointment.
Example:
A customer is logged into the system today at 4:00PM.
If a customer has an appointment set today at 5:00PM , and the reminder minutes as 10.
This invokes a popup with beepsound that has to appear today at 4:50PM(i.e 10 minutes before the actual appointment start time).
I have all appointments with start time, end time , (along with the dates) stored in backend table for number of customers.
Please guide me to achive the following in realtime :
(1) to invoke this popup at 4.50PM
(2) play the soundfile stored in the database
From my search,there is a way to do this using signalr concept in mvc. I went through the sample for chat application in this lnk.
http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
This invokes the hub when a event occurs. but in my application it has to work as a reminder to show the popup if the start time matched the current time. how to get this in real time. Any idea can help me.
This could be a good situation to use WebSockets. (Take a look at Socket.IO, and it's .NET version SocketIO4Net)
The idea would be to have a business logic server side to manage what customer has an appointment to be reminded. Then it uses the WebSocket to send the reminder signal. If the customer is logged in, the js client side would catch the signal and you decide how you want to show it.
To play the sound stored in the database, you could do an action server side that returns the sound file or something, and then use an HTML 5 tag to play the sound.
Hope this helps.
Everything can be done but as ChristianDev says SignalR does not work like this out of the box... I think you can do this with SignalR anyway but you have a few challenges...
You have to maintain state on the server for the clients appointment
This state have to be persistent between connection, when a client navigates between pages
When an event fires you have to send the message to the correct client
If that client is between pages (offline) at the moment that message have to be stored until the client gets back online and then be sent to him/her.
EDIT: It seemed like a fun thing to write so a wrote a simple notification application. You can probably port it to SignalR pretty easy. Realtime Notification Sample
You could change the approach, and use a windows service, emailing/sms'ing the user to remind them of the appointment, this means that the user doesn't need to be logged into the web application to receive a reminder.
If you wanted to use technology such as SignalR, you would need to keep a record of connected users (and their username) and then when an appointment is due, you would need to trigger an event to send to the user in question, based on the unique connectionId.
SignalR, out of the box, doesn't work like this - but, take a look at my question here for some help : Update UI with SignalR and Knockout when manually updating DB
Edit: To add to this, if you're looking for a very nice notification plugin, then take a look at John Papa's ToastR, it's a small JS/Css plugin which notifies via a 'timed, outlook style notification'.
Related
I have a MVC C# Webpage. I use NodeJs express module for a real time chat feature.
The real time chat works well, I am however a novice in NodeJs.
In my chat page, users can add a favorite lists of users they like to chat with. What I want to do is put a green or red dot next to each user in their favorites list so they can see who is online.
Keeping track of every users online status is fairly straight forward, even without Node JS. I could just make a a simple ajax call on every action in the page which updates the users last activity. If the activity is less than 10 minutes old, my site will consider them online.
However the problem comes when I want that status to be shown in real time to the user in the chat page. Each user may have 20-30 users in their list. So ajax polling every minute or so, sounds a like it may get a bit messy? (200 users polling the server every minute asking about 30 other users status)
What logic is best used in a situation like this?
I'm working on a C# MVC 4 application and I want to make a notification system much like facebook.
I thought about adding a notification in a table for each event, and then make AJAX calls to the database each 1 minute to retrieve notifications for the current user.
But I'm afraid it's too heavy.
Your best bet would be to go with SignalR. Its designed for the purpose of real time notification
introduction-to-signalr
Currently I have an application in which a user stares at a dashboard, the dashboard will display new orders coming in for that user. I have rolled out the application for testing and most users are complaining of time delays and crahsing.
Currently I am using jQuery and Ajax using setInterval() and then an Ajax call to get the orders and update the screen every 30 seconds. However in some instances where there are a lot of orders the Ajax calls become overlapped.
I have stumbled across a new technology to me which seems like the solution SignalR but I have looked at the examples and have not seen any comments on performance.
Question - What is the performance like and would it be a better solution to the current above, also is it possible to configure this to target only a specific user and can this be done to the current logged in user's ID? I am using MVC4.
Any comments would be appreciated,
Thanks
You can use SignalR to send messages to a specific client/user. Take a look at the documentation here to find out more about this: https://github.com/SignalR/SignalR/wiki. SignalR allows you to make remote procedure calls (RPC's) from the client and the server and you should be able to push any notifications/new orders to the client almost immediately.
There aren't any published performance metrics for SignalR as yet but you can test it out to see how efficiently your traffic is handled.
I have a web service that takes user location periodically.
I want to create a desktop application that takes those values and shows the real time position of user on a map automatically.
What is the best method I can follow to get real time updates?
Can I use Ajax? Does it support auto refresh?
Is there a better method which supports auto refresh and also display real time data?
Thank you..!
Check out the SignalR library. There is a server-part and a clients part (Javascript, rich client) etc.).
You could trigger the update in the client if the WebService was called. So the client is notified and could update his data accordingly.
How many clients are connected? Maybe some other message bus like library would be more appropriate?
What if I have website with a button. User clicks on the button and starts a long running process. After a few hours (or minutes) user update webpage and see results. What is the best (and any other) way to implement long running operation on website?
From the user experience point of view I suggest you implement the job like you would implement order handling in an online shop.
When the user starts the job he should be able to track the state of the job. Is the job complete? Did the job fail? What is the progress of the job? He should probably also be able to cancel the job and perhaps modify properties of the job. You could implement an notification mechanism using e-mail or an SMS and the user should be able to control that.
By using JavaScript/AJAX you can provide a more interactive user experience where the job status web page is automatically refreshed at regular intervals in the background without forcing the user to refresh his browser.
The user should be able to leave his computer and later connect to the website from another computer and still be able to get information about pending and completed jobs. This requires some form of user login.
I suggest that you separate the job handling code from the website code. You could expose the job handling user a web service or another similar technology. The website should query the service and display the results providing a user interface on top of the job service.
How long? If it's really going to take hours, you don't want that code running in the web server. Have the server spawn an external process or start a service or something along that line, and put the long running code in there.
You could have that code put status updates somewhere (like in the database) as it runs, and the website can check that when the user comes back to see how it's doing.
I suggest you read up on Threading in asp.Net. For website performance, time consuming processes can be put on a different thread.
A different approach is executing the task with AJAX. This way, you can present the user interface to the user, and start an asynchronous process which handles the request.