Asked by:
SignalR Suitability for my application

Question
-
User1448655074 posted
Hi All
Currently I'm running a webforms c# application that displays/broadcasts videos from YouTube or Images using iframe tags.
I have an update panel which regularly does an async postback and checks the times and if the time now falls in between a certain specific time window (from a db) then a ScriptManager javascript function is called from code behind which displays (or hides) the appropriate iframe for that time slot.
There is now requests at all from the client but just a pure broadcast from the server.
I've yesterday stumbled upon SignalR and it seems like the perfect tech to do that I want to do - could someone confirm this is possible with this framework?
Also any hints/tips to get me started
thanks
Wednesday, January 3, 2018 1:01 PM
All replies
-
User753101303 posted
Hi,
We would need to better understand the goal. For example someone could decide to now show something else and it should take effect immediately for those looking at this page? It is the kind of things where SignalR could help (ie sending back data from the server, the first SignalR sample was a web based chat application ie someone post a message to the server which is sent immediately by the server to all other connected clients).
Wednesday, January 3, 2018 2:12 PM -
User1448655074 posted
So the end user doesn't decide anything the request is only made from the server.
So for example, between 16:00-16:15, I want to show an image to all the connected clients to the server
between 18:00-19:00 I want to show a iframe video to all connected clients
The client doesn't choose what to see the request is sent from the server to all clients.....
hope this makes sense
Wednesday, January 3, 2018 2:28 PM -
User475983607 posted
I generally set aside some time to get a fundamental understanding of the technology and build a proof of concept.
Other than that SignalR uses Web Sockets to create a persistent connection between the browser and server. Through this connection the client and server can send bi-directional messages. If you feel this might be a good fit then can learn more about SignalR and go through a few tutorials from the Learn link in the menu above.
Wednesday, January 3, 2018 2:42 PM -
User753101303 posted
What I mean is that it depends WHEN the decision is made (ultimately whatever happens client side comes ALWAYS from the server).
If you are a TV, the playlist is defined once for all way before it is played so fetching the playlist from the server each day is more than enough. SignalR would allow to "push" data from the server to all clients to catch a last minute change even after the playlist for the day was downloaded. Until now, I'm really not sure you need that.
"Pure broadcast" doesn't mean much to me. I'm not sure what your customer really want...
If I had to built that from scratch, I would do an Ajax query to get what to do next, would get a message telling what to show and until when and once this delay elapsed I would trigger another Ajax call to know what to do next. For now I see no evidence that SignalR is really needed.
I would make sure first to really understand whay my client asked for... Or told another way what is wrong for him with how it is done currently ?
Wednesday, January 3, 2018 4:23 PM -
User61956409 posted
Hi Poly,
<o:p></o:p>If you’d like to push messages (might be images or videos) to clients on schedule, SignalR can help you implement server broadcast functionality. On your hub server, you can detect current datetime and determine if push specific data to connected clients. I recommend that you can push resource type&url (such as
img|http://xxxxx.png
orvideo|http://xxxxx.mp4
) to clients, and then you can know the type of data and resource url, you can dynamically generate elements to display the image or video on client side. <o:p></o:p>Besides, this tutorial shows how to implement server broadcast functionality using SignalR 2, you can refer to it.<o:p></o:p>
With Regards, <o:p></o:p>
Fei Han<o:p></o:p>
Friday, January 5, 2018 2:47 AM -
User1448655074 posted
thank you
thats what my original thought was - as currently I'm polling every 20 seconds using update panels to check the times and initiating the resources should the time window be met. Yes it works but there is a lot of polling just to time check hence the reason I though this is probably the ideal product for this sort of thing.
I've looked the example its very through and too difficult for me to understand so i'll see If I can find a server broadcast example which is easier to follow.
Potentially I could have 200-500 clients connected concurrently will that be a problem for SignalR?
Friday, January 5, 2018 4:12 PM -
User1448655074 posted
thanks PatriceSc great insight - yes I am using a playlist and your point is spot on
I have tried moving away from updatepanels and using ajax async calls but it just breaks alot of my code due to the handlers disappearing.
Perhaps I'll have a shot at a PoC setup - I just think SignalR make make things alot tidy for me.....
Friday, January 5, 2018 4:16 PM -
User753101303 posted
IMO the first step is to understand the delay between the creation of the data and when it will be consumed.
If an app must show messages and they are created 24 hour before I need to show them, I know I could poll each hour or could easily change the poll frequency without much problem.
Now if a message is new and I won't it to show it as soon as possible (ie I HAVE to poll really often) then this is where I really need SignalR.
So :
- if you poll eveery 20 second before you couldn't get the data before then it seems you need SignalR
- if this is because your Ajax call tells what you should be done just now, it seems you could increase the poll ffrequency by loading what you have to do for the next 30 minutes or for the next hour (if known already) rather than to just get what you want right nowFriday, January 5, 2018 6:50 PM -
User379720387 posted
Let me give you an example of what I have done.
Previously a user would make a change to a setting for an IoT device and I would write the updated setting on the posting of the form to the db.
In the back ground a socket would contact the IoT device and tell it to update this particular setting. Eventually the IoT device would contact the socket and report the setting change was made. Unless the user refreshed the page they would never know this all happened.
With signalR I have a onchange-do-this on that table and it now communicates directly with some js in the client's browser. As soon as that happens the web pages gets updated, without a refresh.
I think your scenario would work with signal R.
Sunday, January 7, 2018 11:12 PM