Brendan Tompkins

Sponsors

The Lounge

Wicked Cool Jobs

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ

A few weeks ago, an article appeared on O'Rielly that showed an example chat application that utilized Amazon's Simple Queue service to store chat messages.  IMO, using a middle-ware Queuing system over a Web Service is a great idea (which was the motivation for me creating www.wsmq.com), and the idea of creating a chat application to demonstrate the features of a Web Service Queue is a good one. So, I borrowed the idea, and set about to create an instant messenger using WSMQ  as the back-end chat storage mechanism.

I wanted to create a 100% Web-based chat, with out resorting to Java or other bits that don't play well in a web browser. The first problem I was faced with was how to make a request to the WSMQ server without refreshing the browser window.  I found a good remote scripting JavaScript library from Alvaro Mendez that allows you to call any method on an ASP.NET page from within client-side JavaScript.  This was the biggest hurdle for creating a usable chat application.  The rest was fairly straight forward.  It involved some relatively simple JavaScript, and some ASP.NET code to connect to WSMQ to queue and receive chat messages.  The architecture ended up looking like this.

How does it work?

  1. A controller page polls for new chat conversations, using a remote scripting (RS) call to the back-end ASPX page control. 
  2. This ASPX control connects to the WSMQ Service and peeks the users queue to check to see if there are any new conversations on the user's chat queue. 
  3. If it finds a new conversation, it returns the user name requesting the new chat to the controller via an RS callback.
  4. The controller launches a new chat window and identifies the chat conversation partner.
  5. Each chat window polls the back-end ASPX page, which connects to WSMQ,  receives the message and returns it to the calling window via a RS callback. 
  6. When the user clicks “Send“ or presses enter in the chat window, a RS call is made to send each message to chat partner's queue. 

Try it out online here, if there's no one else chatting, you can chat with yourself by clicking on your name.  You can download the full project from the WSMQ beta program page.  We're offering free accounts to use WSMQ Hosted version with our Beta program, so sign up if you haven't already. You'll be able to run the web application locally using the WSMQ Hosted queue as the chat message store

-Brendan


Posted Wed, Jan 19 2005 1:50 AM by Brendan Tompkins

[Advertisement]

Comments

Hum wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Wed, Jan 19 2005 6:34 PM
This program rocks, period.
Darrell wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Jan 20 2005 1:14 AM
That's pretty slick. Good job Brendan.
Dave wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Jan 20 2005 12:49 PM
Dude, nice job!
once wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Tue, Mar 1 2005 8:02 AM
Not to knock your solution, but I'm trying to build a chat application right now and I keep running into examples of chat applications that rely on polling the server over and over. Is there any way to build an html based chat that does not poll the server over and over to determine if there are messages available?
Brendan Tompkins wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Tue, Mar 1 2005 8:13 AM
No, by all means, knock away. This was just intended as an example appication for my queuing systmem, WSMQ.

Well, there's no push equivalent in the web browser world, without relying on plugins, so your only real otion is polling.
Gaisa wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Tue, Mar 22 2005 7:38 PM
..."Is there any way to build an html based chat that does not poll the server over and over to determine if there are messages available?"...

I would suggest speaking to "Chicago", the webmaster of www.magnachat.com, he created an html chat program called chatago.
The site is a working example of such and I use it myself.
Harish Nair wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Nov 17 2005 1:18 AM
hi Brendon,

First of all, let me thank you for WSMQ. It is simply wonderful and just the thing that I was searching over the web. I wanted to build a chat application and was considering the idea of saving the messages in the database / files and writing the entire piece of code. WSMQ will save a lot of it. Thanks once again. We tested out the Beta 2 version of it. When is the first version going to be out? Heard it is open source... is it? What would we need to do to use it?

regards
harish
Harish Nair wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Nov 17 2005 1:20 AM
hi Brendon,

First of all, let me thank you for WSMQ. It is simply wonderful and just the thing that I was searching over the web. I wanted to build a chat application and was considering the idea of saving the messages in the database / files and writing the entire piece of code. WSMQ will save a lot of it. Thanks once again. We tested out the Beta 2 version of it. When is the first version going to be out? Heard it is open source... is it? What would we need to do to use it?

regards
harish
Steve wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Apr 27 2006 2:15 PM
http://www.wsmq.com/WSMQInstantMessenger/default.aspx

Is a dead link.  It brings you to the home page.  I don't see any chatting demo on the page even after signing up?
Dave wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Mon, Jun 5 2006 2:05 AM
ali wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Sun, Jun 11 2006 6:59 AM
ldljkfdsfds
sam wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Jun 15 2006 9:49 AM
joe finkz dat u bloodi outragous and dat u shud actuali tell us ow 2 get on2 msn at skool! kool bredrinz !
CHIRAG wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Oct 5 2006 12:11 AM

Really, ur idea is simply gr8, I want to develop a same kind of application , can u guide me to how to i start and how i can start work.

Ritesh Manglani wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Tue, Oct 10 2006 1:54 AM

Great link I have found here guys. No doubt the information is useful, however, it lacks some sample code.

I am trying to develop a chat application, and would like to implement the same...ummmm...I am looking for some sample code so I can get a better understanding of things.

Hope to hear something from you guys soon.

Ritesh

amy jones wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Wed, Oct 18 2006 6:12 AM

yea yea what ever!!!

a wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Oct 26 2006 3:02 AM

a

jha wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Mon, Dec 4 2006 9:23 AM

lemme check it

blih wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Thu, Jan 11 2007 5:12 PM

hello, I tried to build your program and I got  "A project with an output type of class library cannot be started directly" and "The referenced component 'WSMQ.Data.DbProvider' could not be found" while trying to start it with a new project that has WSMQ for reference..

I'm a beginer, please help.

Linto Antony wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Mon, Jan 22 2007 2:19 PM

Lemme check it...

Ana wrote re: Web-Based Instant Messenger with ASP.NET, Remote Scripting and WSMQ
on Tue, Mar 4 2008 7:16 PM

The link to the demo is dead, basically looking t=for a way to develop an IM, has the pooling part done, cant figure out how to open the IM window on the target user browser, or even how to detect if the window has been open an is minimize, any sample code would help, Ana

DotNetKicks.com wrote test
on Tue, Dec 2 2008 3:50 AM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Devlicio.us