CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Brendan Tompkins [MVP]

Blog First. Ask Questions Later.

January 2005 - Posts

  • More Welcomes

    I haven't had any time to blog for the past couple of days, which is killing me! The reason is that I've been spending my free time setting up some great bloggers on CodeBetter.com. It's kind of funny, I feel like I just bought this great new guitar (CodeBetter), but I haven't had a chance to play it yet because all my friends are playing with it.  But In this case, my friends are the equivalent of Hendrix, Page and Django, so I'm not complaining too much. :)

    Anyhow, as my wife likes to say, I'm terrible with analogies, but I wanted to say welcome to Peter van Ooijen, Geoff Appleby (our very own “Rory”, but even better),  Eric WiseBen Reichelt and Jeff Lynch

    Welcome Guys!

    -Brendan

  • Welcome Sahil

    Just added another blog to CodeBetter.Com, Sahil Malik.  Sahil is another DNJ refugee that has decided to join us.  Welcome, Sahil!

    Brendan

  • Create an .exe File for a PowerPoint 2003 Presentation

    You may have noticed that you can't package up a powerpoint into an .exe file anymore, with PowerPoint 2003.  The option is just gone, and that kinda, well can suck. Especially when you need to send a PowerPoint, or put one on CD.  Well, today, I fount this article at www.presentations.com that explains how to do it.

    Create an EXE file from PowerPoint 2003? Yes, it can be done

    This just saved the day for me!

    -Brendan

  • Welcome to CodeBetter.Com, and Introductions

    Thanks for visiting CodeBetter.Com.  I wanted to introduce the other bloggers that have moved over here, if you don't already know them. 

    Grant Killian

    Grant is one of the most dedicated .NET community leaders I know.  He's the brains behind www.WeProgram.net, the local .NET user group here. On a personal note, he's a super nice guy, up for anything (so ask him to a beer if you're in town), and one hell of  a Cricket player.

    Darrell Norton

    Well, everyone knows Darrell, so he really needs no introduction, but if you've been in a spider hole somewhere, Darrell is one of the most prolific .NET bloggers around.  He tears through every book on software development out there, and usually writes up great reviews when he's done.  He also has every MS certification known to man, and even a few that no one knows about.   He's a C#/Python/SQL expert to boot.  On a personal note, if you see someone driving past you, bumping with bass, with a CSRULZ license plate, it's probably Darrell.

    Paul Laudeman

    Paul taught me everything I know about n-tier software development.  He's a hard-core coder, the kind of guy that puts a do-not-disturb sign on his office and comes out three days later with a complete solution to the stickiest part of a project.  On a personal note, he's a gamer, so if CodeBetter.Com ever becomes it's own country and is attacked by the horde, we're in good hands.

    We're hoping to add some more folks, some forums, and other good stuff, so stay tuned... Thanks for stopping by! 

    -Brendan

  • End User Sessions When the Browser Closes With Remote Scripting

    I literally stumbled across this solution while creating the WSMQ Instant Messenger demo that I posed about last week.   My problem was that I needed a way to log users out of the chat application when they closed their browser window.  Since I was storing my list of users in the application, they'd hang around indefinitely unless I manually pulled them out, or until the worker process restarted.

    Then it occurred to me that this may also work as a mechanism to automatically time out a users session when they close their browser.  On a big website, you could have hundreds of sessions sitting around taking up memory, that aren't being used.  Depending on what you've decided to load the session up with, this could be a resource hit for your web server.  By default, these sessions will timeout after 20 minutes, but with this method, you can time them out as soon as the user closes their browser. 

    The solution requires using this Remote Scripting Java Script library from Alvaro Mendez that allows you to call any method on an ASP.NET page from within client-side Java Script.  It also requires that pages in your site inherit from a PageBase class (which is good practice and hopefully you're doing this anyway).

    Step 1 - Add the RemoteScripting.cs file to your project

    This just has to live somewhere in your project, or in a referenced DLL.  If you have a [Your Namespace].Web project, this would be a good place to put this so that you can re-use it across web applications.

    Step 2 - Give RemoteScripting a chance to handle each request

    You can do this in a variety of ways, but one sure way is to add the following line of code to your PageBase's OnInit method.  What this will do it let RemoteScripting handle the request if it needs to.  Now, there is a bit of a trade off here, you are adding extra cycles to each request, so you may want to consider the overall payoff here.  It's not much processing if there was no remote method called.

    protected override void OnInit(EventArgs e){
      // If it was called invoke the remote method and get back to the client
      RemoteScripting.InvokeMethod(this);
    }

    Step 3 - Add an EndSession method to your PageBase Class

    This will be the remote method that gets called when the browser window is closed.

    public void EndSession() {
      // This will call the application session on end method.
     
    this.Session.Abandon();
    }

    Step 4 - Include the rs.js Client Side JavaScript Library on your Pages.

    You've got to add the rs.js script which comes with the RemoteScripting to each page.  You could do this in the ASPX code, or pro grammatically in your PageBase.  A good place to do this would be in your OnPreRender method.

    Step 5 - Add a JavaScript event handler to your ASPX page's onbeforeunload event.

    Unfortunately, the following script only works with IE.  If anyone can figure out how to get it to work with Firefox, that would be awesome.  It at least doesn't cause problems in FireFox, so it should be relatively harmless...

    // Wire up the onbefore unload event
    window.onbeforeunload = EndSession;

    // Close all open chat windows, and call the remote method to logout of the application
    function EndSession()
    {
      
    // Get the real ASPX page name
      
    var sPath = window.location.pathname;
      
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
       
    if(sPage == '') sPage = "Default.aspx";

      
    // They're in a  popup window, don't kill the session here!
       
    if(window.opener != null) return;

     

       // Only want to run the endsession for IE, no way to tell currently if it's not IE and
      
    // the window is closing
      
    if(window.event != null) {
        
    var abssize = document.body.offsetWidth-30;
        
    if (window.event.clientY < 0 && event.clientX >= abssize)  {
               RS.Execute(sPage
    , "EndSession");
         }
       }
    }

    That's it!  Now when someone closes their browser, the remote method should be called, and the session gets killed.  I'd recommend that if you try to do this, you do some debugging to make sure that you have everything wired up correctly, since there's no UI component to this.

    Good Luck!

    -Brendan

  • 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

  • My First WeProgram.NET Meeting

    Last night I finally attended a WeProgram.NET meeting.  Geoff Snowman from the MSDN team talked for an hour and a half about Team System (he's taking another Lap Around Team System: Roanoke, VA, Tonight!)   Geoff's talk had us all salivating for VS2005.  I gave a rambling overview of WSMQ, and ended up with some cool give-aways (shwag for all you DNR listeners).

    Grant will be happy to know that I'm kicking myself for not going to one of these earlier.   It really is a great opportunity to get up-close and personal with some very good speakers, to network, get some free stuff, impress your boss, and to top of it all off, it's free! 

    -Brendan

  • Cleaning House (Kept New Bloglines Posts)

    After about a month or so, I end up with a bunch of posts marked “Keep New” that I want to read when I have some spare time.  One good way for me to read them, is to post about them, so here they are:

    I end up marking almost everything I read on Coding Horror (Jeff Atwood).  All excellent stuff and it all seems to be relevant to what I'm doing at the time:

    Happy Talk Must Die

    Hear Hear.  This greatly influenced my design of the www.wsmq.com site.

    The Last Configuration Section Handler..

    I'm always looking for better ways to handle app config.

    The Antidote to ASP.NET Smart Navigation, Part Deux

    I'm using this now at work.  Good stuff.

    And not from Jeff Attwood, some stuff relating to .NET 2.0, that I figure I'd better read soon:

    Features you must read about in .net 2.0 Part 1 (Beta 2)

    Nullable value types

    -Brendan

  • Roy Starts Up Team Agile

    Roy Osherove announced today that he's starting a company, “Team Agile.” 

    Team Agile is a one man show providing training, mentoring and development of materials and infrastructure for organizations wanting to learn more and become a little more Agile.

    Good luck Roy!

  • Good O'Reilly Article on Web Service Queuing

    From Fun With Amazon's Simple Queue Service:

    “I tried to think "out of the box" for my sample SQS application. Why not a chat application? It makes perfect sense, or no sense at all, depending on your perspective.“

    This is really cool!  Yes, even though the Amazon service technically competes with WSMQ, I really don't see it that way.  This idea is so new, and it's so early in the game, that anyone entering the market is good news for everyone.  Plus, who really wants to compete with Amazon? 

    My thoughts on this are that we'll be able to compete with their service in terms of features, security, and .NET integration.  We just gotta get some more samples out there for WSMQ!  Um. How about WSMQ Chat? :)

    -Brendan

  • Bad News for Passport...

    I don't know about you, but I groan everytime I have to use passport.  Well, perhaps something better is planned.
    -B
  • Announcing: WSMQ Hosted Beta Program

    I'm pleased to announce a new hosted version of WSMQ (Web Service Message Queue).  We've completely re-written the majority of the back-end queuing system.  The most notable change to the architecture is the ability to store queues in SQL Server as well as in XML.  We've also added optional encryption, so that the entire queue conversation can be secured. 

    We're planning to run a one-month beta program to help shake out any bugs, and get some community feedback on the application. Visit the WSMQ Registration Page to register for the beta program. With your beta account, you'll be able to securely create queues, queue and dequeue messages through the WSMQ Hosted Web Service.  You can also manage your queues, using an easy-to-use Web application.

    Thanks! 

    -Brendan


    About WSMQ

    Web Service Message Queue (WSMQ) is a simple message queuing alternative for enabling reliable, professional-grade applications. As compared with other popular message queues, WSMQ is easier to deploy, write code for, manage and scale.


     Why WSMQ?

    Like most things, WSMQ grew out of necessity.  Coming from a Microsoft world, we were used to using Microsoft's message queuing product, MSMQ.  From our perspective, MSMQ was overly complex.  This complexity made it difficult to use, deploy, and manage. “Wouldn't it be nice if we had a simple, easy-to-use queuing application, that allowed queuing and receiving messages reliably, without all of the complexity the current queuing applications?” we thought. 

    We thought it would be nice to have a simple queuing application - one that was based on technologies we were familiar with and used to using every day.  Technologies like Microsoft .NET, XML and XML Web Services, Web Service Enhancements, ASPX, SQL Server and IIS.

    We created WSMQ to fit this need and solve our problem, and for us it works great.  We “eat our own dog food,” and use it in our deployed business applications.  We hope you can use it solve your's as well.

More Posts