AspComet

Background

https://github.com/nmosafi/aspcomet

The aim of this project is to provide a lightweight and extensible COMET implementation which does not require a custom server but can run in native IIS under ASP.NET.

Most COMET implementations require a custom server, due to the fact that ASP.NET's threading model (pooled threads) does not promote scalability for COMET applications.

A strong motivation for this project is therefore being able to remove this requirement, and to be able to deploy COMET applications to any shared infrastructure or cloud based hosting. It is packaged as a single .NET DLL coming in at under 40KB in size.

To find out more about COMET, it's worth reading Neil Mosafi's blog post at http://neilmosafi.blogspot.com/2009/03/comet-pushing-to-web-browser.html which describes some of the motivations for this library.

The Bayeux Protocol

Bayeux protocol is a well established publish / subscribe protocol for building COMET servers. By leveraging this protocol, applications which use AspComet will be compatible with a number of JavaScript client libraries, including JQuery.Comet and Dojo.Comet.

AspComet supports "long polling" under the Bayeux protocol, using Asynchronous Http Handlers in ASP.NET, which allows applications to scale to be able to service large number of client sessions.

Find out more background information at Neil Mosafi's blog post here: http://neilmosafi.blogspot.com/2009/03/comet-bayeux-protocol-and-aspnet.html

Getting started

The project uses Jetbrains TeamCity for continuous integration, hosted at TeamCity.CodeBetter.Com. The easiest way to get up and running is to download the most recent artifact from there. Otherwise you can build from source.

Once you have AspComet.dll, you'll need to set up the Http Handler for handling COMET requests. Add a reference to the dll and add the following line to your Web.Config file:

<httpHandlers>
  <add verb="POST" path="comet.axd" validate="false" type="AspComet.CometHttpHandler, AspComet"/>
</httpHandlers>

Then you need to add one line to your Global.asax.cs file:

Setup.AspComet.WithTheDefaultServices();

And that's it! You can now build client applications using a supported Bayeux Javascript client, subscribe to channels and publish messages to them.

Some more advanced scenarios

Responding to events

AspComet provides an event hub which allows the COMET Endpoint hosting application to be notified of certain events (such as new clients connecting). By handling events you can trigger business logic, or send messages back to specific clients or channels. Some events are cancellable meaning the application developer can add logic to their application to stop things from happening, such as a client subscribing to a channel. See the chat sample for examples of this.

Taking complete control

The configuration step described in the Getting Started section - Setup.AspComet.WithTheDefaultServices() - is just provided for the most basic scenarios and doesn't allow you to replace any components of the system.

However, AspComet is built with IoC in mind and is fully configurable via IoC, which lets applications completely replace any internal component of the framework. It uses the Common Service Locator Library to locate the services it needs, and provides metadata for applications to easily configure their container of choice with the default services required by the framework.

The best example if this is to look at the Global.asax.cs file in the Chat sample which uses the Autofac container and replaces a few of the default objects with custom ones.

License

AspComet is licensed under the terms of the MIT License, see the included MIT-LICENSE file.


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值