Audio/Video/Text chat in ASP.Net app - c#

I need to develop a chat system in ASP.Net. I have gone through lots of SO question asked on similar topic, but did'nt find any one satisfactory. Is it possible to create it from scratch or do i need to go for some API's. My requirement is limited to my site users only, can say intranet based.
Please help me.

To make the text chat is one think that you can done with a simple table, everyone write on it, every one read time to time, and you show it to the page.
Here is an example http://www.codeproject.com/KB/ajax/ChatRoom.aspx
The Video/Audio chat is a complicate one. You can start with this example
http://www.codeproject.com/KB/IP/videochat.aspx
and you can read more here: how to work with videos in ASP.NET?

Text chat is relatively simple. It involves three tier architecture. 1) Javascript timer. 2) WCF Ajax Enabled web service or Generic Http Handler, 3) Data Storage (Preferably SQL).
1) On the page - sending: input text box + button (used to send). The button click event handler or the text box's key down (for enter key) and blur events would invoke a post (via JQuery, plain ol' JavaScript or whatever Javascript library you use) to the WCF service/Generic handler, sending the contents of the text box, along with the chartroom name, the addressee, and the recipient.
2) On the server: WCF Service/Generic Http handler receives the post and stores it in DB.
3) On the page - receiving: using JQuery for example, you would create a javascript timer on document ready (when the page loaded). On every timer's tick event you want to create a GET (or post) via your handy JavaScript framework (or Plain Javascript) to your WCF service/ Generic Handler requesting the latest records stored in the DB for that chatroom. Append the result received (assuming xml/html/json) to the Div or whatever element is used to display your "chats".
This is a very simplified chat in jquery/asp.net.
As far as audio-video is concerned, you have a few problems. 1) The browser itself has no means of interacting with the mike, speakers, and video camera, unless it uses a plugin. Moreover, browsers typically have no way of knowing how to decode a video stream (though some of the smarter ones have it built in... chrome, firefox). 3) Javascript has no way interacting with all the necessary hardware as it lives inside the browser.
All that said, you can use a plugin such as Flash or Silverlight, (that has built in access to the necessary hardware), or whatever. You will also have a conceptual dilemma with those as you have to simultaneously deal with 2 streams - one for coming in, another going out and displaying both. However it is possible.

Related

Best way to set up a custom WebHook Receiver in ASP.NET?

We're looking to set up a WebHook receiver in our asp.net application. We've already got a simple aspx document that is able to receive and process the WebHook on the server side when it's received.
While this works, we're pretty sure an aspx file that just grabs and processes whatever is sent to it isn't the best option security-wise. Also, it doesn't need to serve a aspx document back so we figure that's probably a waste of resources.
In the process of looking for alternatives, we've found the following:
The Microsoft.AspNet.WebHooks.Receivers NuGet Package - After some research we discovered that the documentation for this isn't great and every once in a while you'll see mentions of Azure which we don't use. Makes it even more confusing.
Using a handler to do the processing instead of an aspx page - We thought maybe a handler would be able to run just on the server side when a POST is received so we don't need to send a whole aspx page back. This doesn't appear to be a common use for these though.
Any search tips or things we may be missing?

Parsing Data from a website in WP7

This website that keeps updating some live information about the bus timings in Helsinki.
I want to parse the live information from the website and display it on my WP7 phone. The user needs to enter the bus stop number and the WP7 app should show the buses/trams currently in the bus stop.
Is there any way I could obtain the real time information from the website?
If you look at the source of the website (http://www.omatlahdot.fi/omatlahdot/web?command=fullscreen&stop=1020455) -- in IE right-click on the page and select View Source -- you'll see that there's really very little in the actual source file, in particular none of the data is there. All of the hard work is coming from the referenced javascript file scripts/fullscreen_header.js (full path is http://www.omatlahdot.fi/omatlahdot/scripts/fullscreen_header.js). You want to download that .js file and study how it retrieves data with AJAX calls. Start with the reloadPage function.
You can make these same calls (e.g., using WebClient) to retrieve the data into your application. If you want to extract the data from the returned HTML, I'd consider parsing it simply as a string since I am assuming that it would have a very regular structure and dragging in a general-purpose HTML parser would probably be overkill.
Alternatively, you might find out if the omatlahodot.fi provides the data as JSON or XML feeds, so you don't have to "screen-scrape" the HTML. I don't read Finnish, so I can't help you with that. Look around on their websites (maybe a section called "dev" or "api") or send them an email inquiry.
Please let us know how it works out!

How to make the browser back button take you back through AJAX calls?

I have a page with a lot of dynamically generated check boxes on it. As the users click these check boxes a lot of content on the page changes dynamically via ajax. The end users are complaining that after hitting submit and then hitting the back button to change something, their selections are blown away and they have to do it all over again.
I have seen a few sites (gmail, facebook, etc...) use the hash symbol in the URL to hack the back button so that it performs AJAX calls instead of going back to the previous full page request. I would like to do this to modify the URL before the page submits so that hitting the back button will load their previously selected fields.
For instance:
In Gmail if I am viewing my inbox then my URL looks like this: https://mail.google.com/mail/?shva=1#inbox
Then if I click "Sent Mail" an AJAX call is performed and my URL is modified to look like this: https://mail.google.com/mail/?shva=1#sent
I really like this behavior and want to duplicate it. How is this accomplished?
Do your links actually trigger any javascript or do they just link to the URL with the appropriate hash symbol information?
How do you read in the hash symbol info in javascript?
How does this type of navigation affect search engines? Would a search engine know that two URLS that are the same except for the information after the hash are actually different URLs and index them as such?
What are some other pros and cons of this technique that I should take into consideration?
NOTE: I am using C# with ASP.NET Web Forms and ASP.NET MVC 3.0 in case that matters at all.
To manipulate hashtags, look at location.hash (javascript).
You'll also be interested in the new push/pop state stuff in HTML 5. https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history.
github has done some pretty cool things with this. Check out their blog entry on their tree slider feature at https://github.com/blog/760-the-tree-slider.
There's also the jQuery history plugin at http://tkyk.github.com/jquery-history-plugin/. (EDIT: I see Joe beat me to this one).
take a look at the jquery history plugin http://tkyk.github.com/jquery-history-plugin/ I have used it in the past, and it just might do what you want.
JQuery plugin:
http://tkyk.github.com/jquery-history-plugin/
Another jQuery library that I have used in the past:
jQuery BBQ: Back Button & Query Library
Also, a more scaled down version of the previous if you don't need all it's features and just gives you the hashchange event for all browsers:
jQuery hashchange event
NOTE: Just as a brief intro to the above libraries. The hashchange event is supported natively by newer(HTML5 supported) browsers in which case the scripts will just bind to that event. For older browsers that don't support that event, the script creates a polling loop to simulate the event. In either case you can bind to the event and handle appropriately.
EDIT: To answer your questions:
The links do not trigger javascript, links simply change the url with the hash. The hashchange event monitors this action, and when the hash changes(which is logged in browser history stack) the event fires.
location.hash is used to read the hash value, and any appropriate parsing you would need from that point.
Probably not SEO savvy enough to give you a complete answer on that, but fairly sure search engines DO NOT index hashes.
Pros for this technique is usability as your users will be able to properly use their back buttons. Also any history.back(0) javascript calls will also work properly(i don't like them but people use them). Cons are that as you're initially developing, you can get some quirky bugs depending on how your code is written. All in all though, I think with the use of the plugins much of the legwork has been taken out of the process and it is a great method for usability purposes.

C# asp.net asynchronous function call after file is uploaded

I'm facing the following issue:
I have a C# asp.net file upload form with a submit button. After the form is submitted the file is uploaded and post-processing is started. The point is that the post-processing can take up to several minutes.
I would like to create some kind of asynchronous call of the post-processing function with showing information to the user.
So, the steps should be:
file form is submitted by user and upload is started
after the file is uploaded some information is shown to the user (e.g. "Processing..." or some loading-bar animation, etc.)
Meanwhile, the post-processing function is automatically started running in a background
After the post-processing function is finished the user is automatically redirected to another page
When i was searching the Internet I've found several examples but mostly only about asynchrounous call of functions, asynchrounous file upload (PageAsync method, etc.).
Any idea or techniques I should use or some tutorial?
Thanks in advance
That all depends on how fancy you want to get;
Meta-refresh that reloads the page until the background operation is finished
Some kind of ajax call that checks some resource for when the processing is done
HTML5 websockets. if supported, which it probably isn't.
Personally I would use the number 2. and use jQuery to poll the upload page every 500ms or something.
You can use AJAX
http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx
http://vinayakshrestha.wordpress.com/2007/03/13/uploading-files-using-aspnet-ajax-extensions/
http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=upload+using+Ajax&qscrl=1#sclient=psy&hl=en&qscrl=1&source=hp&q=upload+using+Ajax+in+asp.net&aq=f&aqi=&aql=&oq=&pbx=1&fp=db9c4fafd449a821
The jquery/flash control uploadify will allow you to do this easily. They also provide a method for asynchronously calling a method on the event that the file upload completes as described in this comprehensive documentation.
I have looked at a lot of places for a good example, and this is the one I like the best so far.
It does not handle the uploading, but it does a fine job at showing real progress to the user and it is not difficult to implement
http://inov8.wordpress.com/2010/08/29/c-asp-net-creating-an-asynchronous-threaded-worker-process-manager-and-updatepanel-progress-monitor-control/

How can I differentiate between the .net WebBrowser component and an actual browser?

OK, so we have an online downloads store accessed via our software. Recently we've had requests to allow downloads via normal browsers and it's fairly easy just to slap a download page on. The problem is that it would be confusing to people having two download links, one for the software and one for their web browser, so we want to differentiate between the two and only show the relevant download link.
From what I've gathered, the .net WebBrowser component is the same as IE and uses the same User Agent, so we can't use that unless we subclass the WebBrowser in the software to make it use a specific User Agent. It's the more sensible option, but we'd have to roll out another updated version, which is less than ideal.
Are there any other ways to tell if someone's accessing a site via the .net component? My only other alternative is to copy the store to a different address with the different download links and send people there. Again this is doable, but not ideal.
Check if window.external is null. IE implements window.external to have methods like AddSearchProvider where most of time WebBrowser.ObjectForScripting is null.
I'm not sure if there is any better way to do this, but here is one idea... The WebBrowser control has a property Document that gives you access to the DOM object representing the loaded document (after the page is loaded). This object has InvokeScript method that you can use to run some JavaScript in the loaded page.
You could write a simple JavaScript function, say hideWebDownload() that would switch the view to a view used when the application runs locally and invoke it from your WinForms application that hosts the WebBrowser control:
webCtrl.Document.InvokeScript("hideWebDownload");
The default view of the page would show the download link for web and calling this function in the local application would switch the view to local download link.
Have your software pass in an invisible (to the user) value in the querystring of the URL.
Trivial to look if that's present.

Categories

Resources