Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uhyo/socketchat
https://github.com/uhyo/socketchat
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/uhyo/socketchat
- Owner: uhyo
- License: other
- Created: 2011-09-07T09:14:56.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T11:32:11.000Z (about 2 years ago)
- Last Synced: 2024-04-14T07:56:05.976Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 853 KB
- Stars: 4
- Watchers: 4
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.mediawiki
- License: LICENSE
Awesome Lists containing this project
README
== SocketChat ==
WebSocket+MongoDB Chat=== version ===
0.3.0== required ==
* Socket.IO
* node-mongodb-native
* express== event formats ==
->events.txt
== log formats ==
{
name: "String",
time: ISODate,
ip : "String",
comment: CommentObject,
(syslog: true),
}=== CommentObject ===
one of:* "String"
* [ CommentObject, CommentObject, ...]
{
"name":"String", //tag name
"attributes":{
key: value, ...
},
"style":{
key: value, ...
},
"child": CommentObject,
} //makes HTML Element whose name is (name)
== on-browser JavaScript API ==
//Global variable: factory
factory.getChat(function(chat){
chat.api.on("log",function(log){
chat.api.inout("Alice");
chat.api.say("foo",log._id,"bar"); //comment, response, channel
});
});== API formats ==
最初のリクエストでsessionIdを取得した後は、そのsessionIdをリクエストに加えること(sessionId=(String))
=== 定期的なリクエスト ===
GET: /api/==== 入退室 ====
GET: /api/inout?name=(String)==== 発言 ====
GET: /api/say?comment=(String)=== レスポンス ===
==== 通常時 ====
{"error":false,
"userinfos":[Userinfo, Userinfo, ...], //前回から新規にあったユーザーの変更
"myid": 3, //自分のID
"logs": [Logobj, Logobj, ...] //前回から新規に加わった発言。time desc
"sessionid": "abcdefghijklmnopqrst", //自分のsessionId
("inout": Userobj, ) //自分が入室したときに自分の状態を通知
}
===== Userinfo =====
====== ユーザー一覧を完全に取得 ======
{"name": "users",
"users": {
"users": [Userobj, Userobj, ...],
"roms":25, //ROM数
"actives":1,//入室者数
}
}
====== 新しいユーザーが出現 ======
{"name": "newuser",
"user": Userobj
}
====== 既存のユーザーが入退室 ======
{"name": "inout",
"user": {
"rom": false, //ROMかどうか
"id": 3, //ユーザーのID
"name": String, //ユーザーの名前
}
}
====== ユーザーが消滅 ======
{"name":"deluser",
"id": Id //ユーザーのID
}
==== エラー時 ====
{"error":true,
"errormessage":String
}
== Hashtag validation ==
* スペースを含まない
* #を含まない
* スラッシュで始まらない
* スラッシュで終わらない
* スラッシュが連続しない