Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
liuding committed Feb 29, 2016
1 parent 3ce775c commit b1afcca
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 109 deletions.
8 changes: 4 additions & 4 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ goim
* 轻量级
* 高性能
* 纯Golang实现
* 支持单个、多个以及广播消息推送
* 支持单个、多个、单房间以及广播消息推送
* 支持单个Key多个订阅者(可限制订阅者最大人数)
* 心跳支持(应用心跳和tcp、keepalive、http long pulling)
* 支持安全验证(未授权用户不能订阅)
* 多协议支持(websocket,tcp,http
* 多协议支持(websocket,tcp)
* 可拓扑的架构(job、logic模块可动态无限扩展)
* 基于Kafka做异步消息推送

Expand All @@ -39,8 +39,8 @@ kafka在官网已经描述的非常详细,在这里就不过多说明,安装
1.下载源码(根据自己的系统下载对应的[安装包](http://golang.org/dl/))
```sh
$ cd /data/programfiles
$ wget -c --no-check-certificate https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz
$ tar -xvf go1.5.linux-amd64.tar.gz -C /usr/local
$ wget -c --no-check-certificate https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz
$ tar -xvf go1.5.2.linux-amd64.tar.gz -C /usr/local
```
2.配置GO环境变量
(这里我加在/etc/profile.d/golang.sh)
Expand Down
4 changes: 2 additions & 2 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ goim
* Light weight
* High performance
* Pure Golang
* Supports single push, multiple push and broadcasting
* Supports single push, multiple push, room push and broadcasting
* Supports one key to multiple subscribers (Configurable maximum subscribers count)
* Supports heartbeats (Application heartbeats, TCP, KeepAlive, HTTP long pulling)
* Supports authentication (Unauthenticated user can't subscribe)
* Supports multiple protocols (WebSocket,TCP,HTTP
* Supports multiple protocols (WebSocket,TCP)
* Scalable architecture (Unlimited dynamic job and logic modules)
* Asynchronous push notification based on Kafka

Expand Down
50 changes: 1 addition & 49 deletions doc/en/proto.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,5 @@
# comet and clients protocols
comet supports three protocols to communicate with client: HTTP long polling, WebSocket, TCP

## http long polling

**Request URL**

http://DOMAIN/sub?param=value

**Request Method**

GET

**Request Parameters**

| parameter | is required | type | comment|
| :----- | :--- | :--- | :--- |
| ver | true | int | Protocol version |
| op | true | int | Operation |
| seq | true | int | Sequence number (Server returned number maps to client sent) |
| t | true | string | Authentication ticket. User to verify and get user's real ID |
| cb | false | string | jsonp callback |

**Response Result**

```json
{
"ver": 102,
"op": 10,
"seq": 10,
"body": {"data": "xxx"}
}
```

**Response Fields**

| response key | type | comment|
| :----: | :---: | :-----:|
| ver | int | Protocol version|
| op | int | Operation |
| seq | int | Sequence number|
| body | json | The JSON message pushed |

**HTTP response code**

| response code | comment |
| :---- | :--- |
| 200 | Success |
| 403 | Authenticate failed |
| 500 | Internal Server Error|
comet supports two protocols to communicate with client: WebSocket, TCP

## websocket
**Request URL**
Expand Down
18 changes: 17 additions & 1 deletion doc/en/push.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ push HTTP interface protocols for pusher
| :---- | :---- | :---- |
| [single push](#single push) | /1/push | POST |
| [multiple push](#multiple push) | /1/pushs | POST |
| [room push](#room push) | /1/push/room | POST |
| [broadcasting](#broadcasting) | /1/push/all | POST |

<h3>Public response body</h3>
Expand Down Expand Up @@ -54,11 +55,26 @@ curl -d "{\"u\":[1,2,3,4,5],\"m\":{\"test\":1}}" http://127.0.0.1:7172/1/pushs
}
</pre>

##### room push
* Example request

```sh
curl -d "{\"test\": 1}" http://127.0.0.1:7172/1/push/room?rid=1
```

* Response

<pre>
{
"ret": 1
}
</pre>

##### Broadcasting
* Example request

```sh
curl -d "{\"test\": 1}" http://172.16.0.239:7172/1/push/all
curl -d "{\"test\": 1}" http://127.0.0.1:7172/1/push/all
```

* Response
Expand Down
49 changes: 1 addition & 48 deletions doc/proto.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,5 @@
# comet 客户端通讯协议文档
comet支持三种协议和客户端通讯,http long polling, websocket, tcp。
## http long polling

**请求URL**

http://DOMAIN/sub?param=value

**HTTP请求方式**

GET

**请求参数**

| 参数名 | 必选 | 类型 | 说明 |
| :----- | :--- | :--- | :--- |
| ver | true | int | 协议版本号 |
| op | true | int | 指令 |
| seq | true | int | 序列号(服务端返回和客户端发送一一对应) |
| t | true | string | 授权令牌,用于检验获取用户真实用户Id |
| cb | false | string | jsonp callback |

**返回结果**

```json
{
"ver": 102,
"op": 10,
"seq": 10,
"body": {"data": "xxx"}
}
```

**字段说明**

| 返回值字段 | 字段类型 | 字段说明 |
| :----: | :---: | :-----: |
| ver | int | 协议版本 |
| op | int | 指令 |
| seq | int | 序列号 |
| body | json | 业务方推送数据(必须是json) |

**http状态吗说明**

| 返回码 | 说明 |
| :---- | :--- |
| 200 | 请求成功 |
| 403 | 认证失败 |
| 500 | 内部错误 |
comet支持两种协议和客户端通讯 websocket, tcp。

## websocket
**请求URL**
Expand Down
28 changes: 23 additions & 5 deletions doc/push.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ push http接口文档,用于推送接口接入
<h3>接口汇总</h3>
| 接口名 | URL | 访问方式 |
| :---- | :---- | :---- |
| [单个推送](#单个推送) | /1/push | POST |
| [批量推送](#批量推送) | /1/pushs | POST |
| [单人推送](#单个推送) | /1/push | POST |
| [单消息多人推送](#单消息多人推送) | /1/pushs | POST |
| [房间推送](#房间推送) | /1/push/room | POST |
| [广播](#广播) | /1/push/all | POST |

<h3>公共返回码</h3>
Expand All @@ -23,7 +24,7 @@ push http接口文档,用于推送接口接入
</pre>


##### 单个推送
##### 单人推送
* 请求例子

```sh
Expand All @@ -39,7 +40,7 @@ curl -d "{\"test\":1}" http://127.0.0.1:7172/1/push?uid=0
}
</pre>

##### 批量推送
##### 单消息多人推送
* 请求例子

```sh
Expand All @@ -54,11 +55,26 @@ curl -d "{\"u\":[1,2,3,4,5],\"m\":{\"test\":1}}" http://127.0.0.1:7172/1/pushs
}
</pre>

##### 房间推送
* 请求例子

```sh
curl -d "{\"test\": 1}" http://127.0.0.1:7172/1/push/room?rid=1
```

* 返回

<pre>
{
"ret": 1
}
</pre>

##### 广播
* 请求例子

```sh
curl -d "{\"test\": 1}" http://172.16.0.239:7172/1/push/all
curl -d "{\"test\": 1}" http://127.0.0.1:7172/1/push/all
```

* 返回
Expand All @@ -68,3 +84,5 @@ curl -d "{\"test\": 1}" http://172.16.0.239:7172/1/push/all
"ret": 1
}
</pre>


0 comments on commit b1afcca

Please sign in to comment.