Permalink
Browse files

Create

  • Loading branch information...
zzdhidden committed Feb 19, 2010
0 parents commit 6fdaf37a2e4b4efa8d21322e5a0fe376dba3e383
@@ -0,0 +1,68 @@
PREFIX = .
BUILD_DIR = ${PREFIX}/build
DOCS_DIR = ${PREFIX}/docs
DIST_DIR = ${PREFIX}/dist
SRC_DIR = ${PREFIX}/src
BASE_FILES = ${SRC_DIR}/core.js\
${SRC_DIR}/objectExtend.js\
${SRC_DIR}/ajax.js\
${SRC_DIR}/json.js\
${SRC_DIR}/comet.js\
${SRC_DIR}/cookie.js\
${SRC_DIR}/log.js\
${SRC_DIR}/webim.js\
${SRC_DIR}/setting.js\
${SRC_DIR}/status.js\
${SRC_DIR}/buddy.js\
${SRC_DIR}/room.js\
${SRC_DIR}/notification.js\
${SRC_DIR}/history.js \
${SRC_DIR}/hotpost.js\
WEBIM_FILES = ${SRC_DIR}/intro.js\
${BASE_FILES}\
${SRC_DIR}/outro.js
WEBIM_VER = `cat ${PREFIX}/version.txt`
DATE=`svn info . | grep Date: | sed 's/.*: //g'`
REV=`svn info . | grep Rev: | sed 's/.*: //g'`
#REPLACE = sed 's/Date:./&'"${DATE}"'/' | \
sed 's/Revision:./&'"${REV}"'/' | \
sed s/@VERSION/${WEBIM_VER}/
REPLACE = sed s/@VERSION/${WEBIM_VER}/
MINJAR = java -jar ${BUILD_DIR}/yuicompressor-2.4.2.jar
UNICODE = native2ascii -encoding utf-8
WEBIM_JS = ${DIST_DIR}/webim.js
WEBIM_MIN_JS = ${DIST_DIR}/webim.min.js
all: dist min
@@echo "webim build complete."
dist:
@@mkdir -p ${DIST_DIR}
@@cat ${WEBIM_FILES} | \
${REPLACE} > ${WEBIM_JS};
@@echo "Merge"
min:
@@echo "Building"
@@echo " - Compressing using Minifier"
@@${MINJAR} --type js ${WEBIM_JS} > ${WEBIM_MIN_JS}
@@echo ${WEBIM_MIN_JS} "Built"
clean:
@@echo "Removing Distribution directory:" ${DIST_DIR}
@@rm -rf ${DIST_DIR}
2 TODO
@@ -0,0 +1,2 @@
core: JSON 重写,json2.js
status: cookie重写
Binary file not shown.
@@ -0,0 +1,231 @@
流程:
打开页面时,获得页面陌生人stranger_ids,从cookie获取当前已打开的窗口buddy_ids、 room_ids,上线webim/online获得在线buddy_online_ids和已打开窗口的信息和历史记录。此时不用获得所有在线好友信息以减少每次刷新页面读取好友表。setting信息存在session里减少查询。
刷新页面webim/refresh 退出当前client。
----------------------notice---------------------
群组id必须不同于联系人id
----------------------data-----------------------
key: "8633d182-b7fe-42a3-8466-0c4134cfebf2"
connection: //连接信息
{
"domain": "www.uchome.com",
"ticket": &key,
"server":"http://ucim.webim20.cn:8000"
}
userInfo: //用户信息
{
"id":"2",
// "jid":"2@www.uchome.com", //jabber id
"name": "test",
"pic_url":"http://www.uchome.com/uc/ucenter/avatar.php?uid=2&size=small&type=virtual",
"url":"space.php?uid=2",
"show":"away",// ['available', 'away', 'chat', 'dnd', 'busy', 'invisible']
"status":"I'm not here right now.",
"status_time":"10:55"
}
buddyInfo: //联系人信息
{
"id":"2",
// "jid":"2@www.uchome.com",
"name":"test",
"group": "friend", //["friend", "stranger"]
"pic_url":"http://www.uchome.com/uc/ucenter/avatar.php?uid=2&size=small&type=virtual",
"default_pic_url": "", //默认显示图片
"url":"space.php?uid=2",
"presence":"online", //["online", "offline"]
"show":"away",// ['available', 'away', 'chat', 'dnd', 'busy', 'invisible']
"status":"I'm not here right now.",
"status_time":"10:55"
}
roomUserInfo:
{
"id": 2,
// "jid":"2@www.uchome.com",
//"presence":"online", //["online", "offline"]
"name":"test"
}
roomInfo: //群组信息
{
"id":"2",
// "jid":"2@www.uchome.com",
"name":"test",
"pic_url":"http://www.uchome.com/uc/ucenter/avatar.php?uid=2&size=small&type=virtual",
"default_pic_url": "", //默认显示图片
"url":"group.php?uid=2",
all_count:10, //all members count
count: 5,//online members count
blocked: false,
members:[&roomUserInfo] // online members
}
buddies:
[&buddyInfo]
rooms:
[&roomInfo]
logItem:
{
"type": "msg",
"to": "2",
"from": "2",
"style": "color:#bbb;", //
"body": "\uff1f",
"timestamp": "1246883572400"
}
histories:
{
1:[&logItem],
2:[&logItem]
}
----------------------url------------------------
webim/online POST
params
{
buddies: "1,34,34", //通过前端获得的buddy列表
rooms: "1,34,34", //通过前端获得的room列表
presence_buddies: "34,23", //前端需显示的buddy
presence_rooms: "1,3" //前端需显示的room
}
response
{
server_time: "", //服务器时间microtime(true)*1000
user: &userInfo,
connection: &connection,
setting: {},
online_buddies: "54,22", //在线buddy
presence_buddies: &buddies, //根据presence_buddies参数和离线消息from ids取得联系人信息
presence_rooms: &rooms, //根据presence_rooms参数取得群组信息
histories: &histories, //根据presence_buddies , presence_rooms和离线消息from ids取得消息历史记录
new_messages: []//未收到的离线消息
}
webim/offline POST
params
&connection
response
ok
webim/refresh POST
params
&connection
response
ok
//buddy
webim/buddies GET
params
{
ids:"1,2"
}
response
&buddies
//room
webim/rooms GET
params
{
ids:"1,2"
}
response
&rooms
webim/join POST
params
&connection
{
id:"1"
}
response
&roomInfo
webim/leave POST
params
&connection
{
id:"1"
}
response
webim/members GET
params
&connection
{
ids:"1"
}
response
{
10001:[&roomUserInfo],
10002:[&roomUserInfo]
}
//message
webim/histories GET
params
{
ids:"1,2"
}
response
&histories
webim/message POST
params
&connection
{
type: "unicast", //[unicast, multicast] 一对一buddy, 一对多room
offline: 1, //to 离线消息
to: "11",
body: "sdf",
style: "color:red"
}
response
ok
webim/clear_history POST
params
{
ids:"1,2"
}
response
ok
//status
webim/status POST
params
&connection
{
to: "11",
show: "typing" //[typing]
}
response
ok
//setting
webim/setting POST
params
{
play_sound: true,
buddy_sticky: true,
minimize_layout: false,
msg_auto_pop: true
}
response
ok
-------------------------end----------------------
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>webim - test</title>
<link href="css/core.css" media="all" type="text/css" rel="stylesheet"/>
<!-- base start -->
<script type="text/javascript" src="src/core.js" ></script>
<script type="text/javascript" src="src/objectExtend.js" ></script>
<script type="text/javascript" src="src/ajax.js" ></script>
<script type="text/javascript" src="src/json.js" ></script>
<script type="text/javascript" src="src/comet.js" ></script>
<script type="text/javascript" src="src/cookie.js" ></script>
<script type="text/javascript" src="src/log.js" ></script>
<!-- base end -->
<!-- webim start -->
<script type="text/javascript" src="src/webim.js" ></script>
<script type="text/javascript" src="src/setting.js" ></script>
<script type="text/javascript" src="src/status.js" ></script>
<script type="text/javascript" src="src/buddy.js" ></script>
<script type="text/javascript" src="src/notification.js" ></script>
<script type="text/javascript" src="src/history.js" ></script>
<script type="text/javascript" src="src/hotpost.js" ></script>
<!-- webim end -->
</head>
<body>
<div id="wrap-body">
<div id = "webim-log">
<p>
<b>log</b>
</p>
</div>
</div>
<script type="text/javascript" src="index.js" ></script>
</body>
</html>
@@ -0,0 +1,27 @@
var path = "";
//webim.extend(webim.setting.defaults.data,{});
//webim.extend(webim.setting.defaults.data,{block_list: ["1000001"]});
path = document.location.href.split("/webim");
path = path.length > 1 ? (path[0] + "/") : "";
var log = webim.log;
webim.defaults.urls = {
online:path + "webim/online.php",
offline:path + "webim/offline.php",
refresh:path + "webim/refresh.php",
message:path + "webim/message.php",
status:path + "webim/status.php"
};
webim.setting.defaults.url = path + "webim/setting.php";
webim.history.defaults.urls = {
load: path + "webim/histories.php",
clear: path + "webim/clear_history.php"
};
webim.room.defaults.urls = {
member: path + "webim/members.php",
join: path + "webim/join.php",
leave: path + "webim/leave.php"
};
webim.buddy.defaults.url = path + "webim/buddies.php";
webim.notification.defaults.url = path + "webim/notifications.php";
var im = new webim();
Oops, something went wrong.

0 comments on commit 6fdaf37

Please sign in to comment.