C# observer pattern message filtering - c#

I'm writing a video cms and want all my users to have new assets displayed immediately as they come in.
If I'm right, facebook updates its wall-page in realtime. So when I post something to a friend it immediately displays on his wall. The realtime web, as they say.
I wonder how you do that? Not the technology of client-server-communication, but what goes on on the server.
I understand the principles of the observer-pattern.
But a wall is in fact a query on a table of messages.
How does the observer know what query a user is interested in?
Does it hold all the query's of all connected users and reruns it when something new comes in.
I believe Google-realtime works that way to.
Thank you for helping me out.

When you open facebook, open the script timeline in your browser to see what scripts are executing on the page. You'll notice that there is a polling script being executed several times a second. So the page is looking at the cache several times a second to see if there is any new information that can be displayed.
http://www.ajaxwith.com/Poll-vs-Push-Technology.html - this should give you a background on the subject.

Facebook uses AJAX and a JavaScript timer that polls in the background looking for anything that's changed. Other sites use the same type of functionality to update stock quotes embedded in the page, etc. It's not truly updating immediately, it's updating as frequently as the JavaScript timer hits their server. This is because web browsers use HTTP, which is a request/response protocol. A browser won't display anything that's not as a direct response to a request initiated by the browser; there's no way to just send content directly to the browser from your webserver.

Related

SMS client URL preview detection

I have a situation recently identified by the users of my app which i did more than 2 years ago.
To cut the matter short there is a URL link sent to the customer on click of which some things executes based upon the encrypted key that is passed along with the URL query string. Earlier it was working fine because the user had to click on the link in the SMS to execute that. But now a days the SMS clients for example in iPhone or something similar they pick up the URL and try to show the preview (similar to what what's app skype etc do). But the problem is that the link is only one time and on a second click the link is already expired because it is assumed that its already hit.
So, in this situation the user is never able to go to the next step since the link is already consumed in the form of the message preview.
I have a work around for the same for example to show a fake page or something similar but i do not want to use that since i understand that this think i quite common and you genius folks out there have something to share.
Please share how to may be identify the client which are just looking for og tags or how to identify these kinds of clients so that the actual request is not processed unless is done manually by the user by clicking on the link.
As far as I know there is no consistent user agent clients have to use in the open graph spec.
Therefore blocking based on that is an ever moving target, each app could use a different agent if they so wish.
The way I have always countered to this is that a get action should never be a destructive action.
The get should always be safe to run over and over.
If you need a destructive action, the page should include some form of user input/button/link which would trigger a post to the server.
If required you can then also add an added level of security in the link by asking the user to confirm something from the data, e.g. their phone number.
This means if a link was to get into the wrong hands (remember, SMS are not encrypted so can be snooped) then without this information the user is required to enter they will be unable to execute the destructive action of the link.

Keeping track of Online and Offline status in MVC C# webpage with NodeJS

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?

google analytics tracking orders made in web application

So I have ga.js code tracking orders in my web application. These are then picked up in the Conversions-->Tracking-->Transactions section in Google Analytics. The thing is I'm getting average 80-90% of my orders showing up in GA. I've read up online that it is normal that a small percentage of orders wont show up in GA. Is this a correct assumption to make?
Yes it is correct because many users block monitoring sites like that one.
The information is given by javascript call, that is also mean that users with javascript disabled, or get javascript error on page, also fail to send that info to google.
The block can be done either using antivirus/anti malware programs, ether direct by add some site names on the host file of the system and changing the IP to localhost so they fail to run. Its an easy trick if you try to avoid some sites that monitor you.
If you wondering if there is a way to always give that infos regarding if the user blocks it, yes there is, you send that informations on code behind direct on google server, but its a little complicate.
And one tip - better keep that infos for your only.

Ajax or SignalR for order screen

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.

Postback via webservice

I work for a radio station and they want a now playing and coming next on their radio player.
I currently have xml that I will be saving to my live webserver via a webservice. Is there a way to only get the radio player to postback when the xml changes rather than every second via a timer control? We have had performance issues with frequent postbacks in the past so would like to avoid crashing our server. I am using c# asp.net 3.5.
Personally i would recommend doing this with ajax. You can then cache the response at the server side so you dont need to do any heavy lifting in the bulk of requests.
What you want to do is to have your ajax query the server every 10s or so to get the current and next song as a json response. Take the response and put it into your page.
In asp.net you could also possibly do this with an update panel but this would cause significantly more load on both the server and the client.
Comet solution or ETag may help

Categories

Resources