title: So... ASP.NET MVC and WebSockets?
body: <p>I have an application in MVC 3 and I'm looking to add WebSockets (with fallback to Comet) to it.</p>
  
  <p>I've researched a bit and I found out the Comet part is pretty straightforward and I'd much rather do it myself. Just AsyncControllers and a pretty plain bit of js is all that's required to handle those long-lived ajax requests.</p>
  
  <p>Now, in the case of WebSocket, things start to get dirty. I've looked at a few libraries, but they mostly seem to set up a web server (therefore needing another host, or port) of their own, and listen to ws protocol requests there. This is the case for instance for <a href="http://superwebsocket.codeplex.com/">SuperWebSocket</a>, which seemed nice at first, but had this "I'm a web server" issue (which is perfectly fine of course, but I'd rather avoid).</p>
  
  <p>Then I looked at "PingIt" or something like that, I can't find the link now.., I do have the source on another computer though. This one DOES run on an endpoint in mvc, but I didn't quite like the way in which it handles things, like it takes an IDisposable object and through reflector it creates a javascript piece that gets rendered in the client, which is very polluted with their library's name, which I've really no interest in, plus it felt like a lot of it was being thrown in against what I might wish, which kind of goes against my view on how a page should be rendered like (specially now that I'm working on MVC which pretty much means I can code clean, unobtrusive html pages).</p>
  
  <p>Basically what I want is my endpoints to be something like:</p>
  
  <blockquote>
    <p>domain.com/rt/comet<br>
    domain.com/rt/socket</p>
  </blockquote>
  
  <p>rather than</p>
  
  <blockquote>
    <p>domain.com/rt/comet<br>
    domain.com:81/</p>
  </blockquote>
  
  <p>So: is it possible to receive websocket connections (and do handshaking and whatever needs to be done) on an endpoint within an asp.net MVC application's controller, rather than setting up a tcplistener somewhere?</p>
  
  <p>This would also help me keep my comet code a little closer to my websocket code</p>
  
  <p>I should say I'm seriously new to the whole comet/websockets thing, so I don't really know much (or any) of the protocol, I do understand how to make comet work, but not so much in websockets, though I've read and understood the basics to get the gist of it.</p>
  
  <p>Also: please let me know if what I'm asking is way off</p>