Giter Site home page Giter Site logo

ccomet's Introduction

CComet

CComet is a tiny Comet based on EventServer and it is developed and maintained by Yulong Tian. To be specific, CComet uses the http module provided by EventServer.

Comet is a technology for push-notification server. It allows a web server to push data to a browser through HTTP protocal. In other atomsphere, such as android and windows phone, it can behaves GCM and MPNS.

CComet can be used as the messaging server of many applications. To demonstrate the use of the library, I have provided a webchat demo in this project. In future, I will also provide sdks for android and windows phone apps.

Our work is mainly inspired by icomet and I have taken many interesting idea from ideawu, both from blogs and source code. Thanks for ideawu. Thanks again for OSC (Open Source Community).

Usage

1. Start the server.

git clone https://github.com/mathetian/CComet
cd CComet
make ccomet
cd bin
./comet

And run the web-demo in directory demo/web/

2. Run the chat demo

  1. Compile and start ccomet server
  2. Drag and drop the file demos/web/chat.html into one web browser
  3. Drag and drop the file demos/web/chat.html into another different web browser
  4. Start chatting!

Client API

We provide a client api of javascript in CComet.

function CComet(config)
{
	var self = this;
	var sign_sta = false;
	self.seqid = 0;
	self.sub_url  = config.sub_url;
	self.pub_url  = config.pub_url;
	self.sign_url = config.sign_url;
	self.callback = config.callback;

	self.sign = function(){
	    /// For detail information, please seek for the ccomet.js
	}

	self.sub = function(){
	    /// For detail information, please seek for the ccomet.js
	}
	
	self.pub = function(content){
	    /// For detail information, please seek for the ccomet.js
	}

	self.sign();
}

Performance

CComet   :   version 1.0
Date     :   Sunday June 20 20:24:47 2014
CPU      :   4 * Intel(R) Core(TM) i5-3317U CPU @ 1.70GHz
CPUCache :   3072 KB
G++      :   4.8.1
Demux    :   EPoll
Phy-Mem  :   3888 MB

In the benchmark of EventServer, we have found out the QPS and the memory cost of each connection of http module. We will discuss the cost of memory when we add a layer of ccomet.

Connections VIRT RES
0 24M 8M
10000 33M 10M
50000 60M 36M
100000 106M 81M
200000 210M 162M

0.92 KB per connection ?

Discussion : Through our experiments, we have proved the stability of our system.

Design Principle

  1. Use jsonp to solve CORS which is short for Cross-Origin Resource Sharing, problems.
  2. Long-polling instead of polling. To solve some problem in jsonp, I use a timeout 30 seconds, which is a reasonable value, in produce mode.
  3. Compared with icomet, I remove authetication flow and support for iframe technology.

CComet UML Graph

CComet UML Graph

Role in Produce Atmosphere

ROLE

License

This client is licensed under the same license as EventServer. And this license will be restricted by the license of icomet.

Todo List

  1. Android & Windows Phone 8
  2. Memory Pool
  3. ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.