Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fenghuo12
zheng
提交
a8e1bab2
Z
zheng
项目概览
fenghuo12
/
zheng
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zheng
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a8e1bab2
编写于
11月 15, 2018
作者:
shuzheng5201314
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加zheng-message技术选型
上级
2371580b
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
5905 addition
and
78 deletion
+5905
-78
zheng-message/README.md
zheng-message/README.md
+10
-0
zheng-message/zheng-message-client/ack-index.html
zheng-message/zheng-message-client/ack-index.html
+117
-0
zheng-message/zheng-message-client/binary-event-index.html
zheng-message/zheng-message-client/binary-event-index.html
+105
-0
zheng-message/zheng-message-client/bootstrap.css
zheng-message/zheng-message-client/bootstrap.css
+4983
-0
zheng-message/zheng-message-client/event-index.html
zheng-message/zheng-message-client/event-index.html
+91
-0
zheng-message/zheng-message-client/index.html
zheng-message/zheng-message-client/index.html
+89
-78
zheng-message/zheng-message-client/js/jquery-1.7.2.min.js
zheng-message/zheng-message-client/js/jquery-1.7.2.min.js
+4
-0
zheng-message/zheng-message-client/js/moment.min.js
zheng-message/zheng-message-client/js/moment.min.js
+6
-0
zheng-message/zheng-message-client/js/socket.io/socket.io.js
zheng-message/zheng-message-client/js/socket.io/socket.io.js
+3
-0
zheng-message/zheng-message-client/namespace-index.html
zheng-message/zheng-message-client/namespace-index.html
+139
-0
zheng-message/zheng-message-client/ssl-event-index.html
zheng-message/zheng-message-client/ssl-event-index.html
+90
-0
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/AckChatLauncher.java
...c/main/java/com/zheng/message/server/AckChatLauncher.java
+59
-0
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/BinaryEventLauncher.java
...in/java/com/zheng/message/server/BinaryEventLauncher.java
+38
-0
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/ChatLauncher.java
.../src/main/java/com/zheng/message/server/ChatLauncher.java
+30
-0
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/ChatObject.java
...er/src/main/java/com/zheng/message/server/ChatObject.java
+31
-0
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/EventChatLauncher.java
...main/java/com/zheng/message/server/EventChatLauncher.java
+32
-0
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/NamespaceChatLauncher.java
.../java/com/zheng/message/server/NamespaceChatLauncher.java
+40
-0
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/SslChatLauncher.java
...c/main/java/com/zheng/message/server/SslChatLauncher.java
+38
-0
未找到文件。
zheng-message/README.md
0 → 100644
浏览文件 @
a8e1bab2
# zheng-message
实时通知系统
## 技术选型
后端:https://github.com/mrniko/netty-socketio
前端:https://socket.io/
zheng-message/zheng-message-client/ack-index.html
0 → 100644
浏览文件 @
a8e1bab2
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
/>
<title>
Demo Chat
</title>
<link
href=
"bootstrap.css"
rel=
"stylesheet"
>
<style>
body
{
padding
:
20px
;
}
#console
{
height
:
400px
;
overflow
:
auto
;
}
.username-msg
{
color
:
orange
;}
.connect-msg
{
color
:
green
;}
.disconnect-msg
{
color
:
red
;}
.send-msg
{
color
:
#888
}
</style>
<script
src=
"js/socket.io/socket.io.js"
></script>
<script
src=
"js/moment.min.js"
></script>
<script
src=
"js/jquery-1.7.2.min.js"
></script>
<script>
var
userName
=
'
user
'
+
Math
.
floor
((
Math
.
random
()
*
1000
)
+
1
);
var
socket
=
io
.
connect
(
'
http://localhost:9092
'
);
socket
.
on
(
'
connect
'
,
function
()
{
output
(
'
<span class="connect-msg">Client has connected to the server!</span>
'
);
});
socket
.
on
(
'
message
'
,
function
(
data
,
ackServerCallback
)
{
output
(
'
<span class="username-msg">
'
+
data
.
userName
+
'
:</span>
'
+
data
.
message
);
if
(
ackServerCallback
)
{
// send ack data to server
ackServerCallback
(
'
server message was delivered to client!
'
);
}
});
socket
.
on
(
'
disconnect
'
,
function
()
{
output
(
'
<span class="disconnect-msg">The client has disconnected!</span>
'
);
});
socket
.
on
(
'
ackevent2
'
,
function
(
data
,
ackServerCallback
,
arg1
)
{
output
(
'
<span class="username-msg">
'
+
data
.
userName
+
'
:</span>
'
+
data
.
message
);
if
(
ackServerCallback
)
{
ackServerCallback
(
'
server message was delivered to client!
'
);
}
});
socket
.
on
(
'
ackevent3
'
,
function
(
data
,
ackServerCallback
)
{
output
(
'
<span class="username-msg">
'
+
data
.
userName
+
'
:</span>
'
+
data
.
message
);
if
(
ackServerCallback
)
{
ackServerCallback
();
}
});
function
sendDisconnect
()
{
socket
.
disconnect
();
}
function
sendMessage
()
{
var
message
=
$
(
'
#msg
'
).
val
();
$
(
'
#msg
'
).
val
(
''
);
var
jsonObject
=
{
'
@class
'
:
'
com.corundumstudio.socketio.demo.ChatObject
'
,
userName
:
userName
,
message
:
message
};
socket
.
emit
(
'
ackevent1
'
,
jsonObject
,
function
(
arg1
,
arg2
)
{
alert
(
"
ack from server! arg1:
"
+
arg1
+
"
, arg2:
"
+
arg2
);
});
}
function
output
(
message
)
{
var
currentTime
=
"
<span class='time'>
"
+
moment
().
format
(
'
HH:mm:ss.SSS
'
)
+
"
</span>
"
;
var
element
=
$
(
"
<div>
"
+
currentTime
+
"
"
+
message
+
"
</div>
"
);
$
(
'
#console
'
).
prepend
(
element
);
}
$
(
document
).
keydown
(
function
(
e
){
if
(
e
.
keyCode
==
13
)
{
$
(
'
#send
'
).
click
();
}
});
</script>
</head>
<body>
<h1>
Netty-socketio Demo Chat
</h1>
<br/>
<div
id=
"console"
class=
"well"
>
</div>
<form
class=
"well form-inline"
onsubmit=
"return false;"
>
<input
id=
"msg"
class=
"input-xlarge"
type=
"text"
placeholder=
"Type something..."
/>
<button
type=
"button"
onClick=
"sendMessage()"
class=
"btn"
id=
"send"
>
Send
</button>
<button
type=
"button"
onClick=
"sendDisconnect()"
class=
"btn"
>
Disconnect
</button>
</form>
</body>
</html>
zheng-message/zheng-message-client/binary-event-index.html
0 → 100644
浏览文件 @
a8e1bab2
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
/>
<title>
Demo Chat
</title>
<link
href=
"bootstrap.css"
rel=
"stylesheet"
>
<style>
body
{
padding
:
20px
;
}
#console
{
height
:
400px
;
overflow
:
auto
;
}
.username-msg
{
color
:
orange
;}
.connect-msg
{
color
:
green
;}
.disconnect-msg
{
color
:
red
;}
.send-msg
{
color
:
#888
}
</style>
<script
src=
"js/socket.io/socket.io.js"
></script>
<script
src=
"js/moment.min.js"
></script>
<script
src=
"http://code.jquery.com/jquery-1.10.1.min.js"
></script>
<script>
var
socket
=
io
.
connect
(
'
http://localhost:9092
'
);
socket
.
on
(
'
connect
'
,
function
()
{
alert
(
'
socketio client connected
'
);
});
socket
.
on
(
'
msg
'
,
function
(
file
)
{
var
arrayBuffer
=
new
Uint8Array
(
file
).
buffer
;
var
blob
=
new
Blob
([
arrayBuffer
]);
var
imgList
=
$
(
'
ul#img-list
'
);
var
li
=
$
(
'
<li/>
'
).
appendTo
(
imgList
);
$
(
'
<div/>
'
).
text
(
file
.
name
).
appendTo
(
li
);
var
img
=
$
(
'
<img/>
'
).
appendTo
(
li
);
var
reader
=
new
FileReader
();
reader
.
onload
=
(
function
(
aImg
)
{
return
function
(
e
)
{
aImg
.
attr
(
'
src
'
,
e
.
target
.
result
);
aImg
.
attr
(
'
width
'
,
150
);
};
})(
img
);
reader
.
readAsDataURL
(
blob
);
});
$
(
document
).
ready
(
function
()
{
var
fileInput
=
$
(
'
#file-field
'
);
fileInput
.
bind
({
change
:
function
()
{
displayFiles
(
this
.
files
);
}
});
function
displayFiles
(
files
)
{
$
.
each
(
files
,
function
(
i
,
file
)
{
if
(
!
file
.
type
.
match
(
/image.*/
))
{
return
true
;
}
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
socket
.
emit
(
'
msg
'
,
e
.
target
.
result
);
};
reader
.
readAsArrayBuffer
(
file
);
});
}
});
</script>
</head>
<body>
Please upload any image file.
<br/>
<br/>
<div>
<input
type=
"file"
name=
"file"
id=
"file-field"
/>
</div>
<div
id=
"img-container"
>
<ul
id=
"img-list"
></ul>
</div>
</body>
</html>
zheng-message/zheng-message-client/bootstrap.css
0 → 100644
浏览文件 @
a8e1bab2
此差异已折叠。
点击以展开。
zheng-message/zheng-message-client/event-index.html
0 → 100644
浏览文件 @
a8e1bab2
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
/>
<title>
Demo Chat
</title>
<link
href=
"bootstrap.css"
rel=
"stylesheet"
>
<style>
body
{
padding
:
20px
;
}
#console
{
height
:
400px
;
overflow
:
auto
;
}
.username-msg
{
color
:
orange
;}
.connect-msg
{
color
:
green
;}
.disconnect-msg
{
color
:
red
;}
.send-msg
{
color
:
#888
}
</style>
<script
src=
"js/socket.io/socket.io.js"
></script>
<script
src=
"js/moment.min.js"
></script>
<script
src=
"http://code.jquery.com/jquery-1.10.1.min.js"
></script>
<script>
var
userName
=
'
user
'
+
Math
.
floor
((
Math
.
random
()
*
1000
)
+
1
);
var
socket
=
io
.
connect
(
'
http://localhost:9092
'
);
socket
.
on
(
'
connect
'
,
function
()
{
output
(
'
<span class="connect-msg">Client has connected to the server!</span>
'
);
});
socket
.
on
(
'
chatevent
'
,
function
(
data
)
{
output
(
'
<span class="username-msg">
'
+
data
.
userName
+
'
:</span>
'
+
data
.
message
);
});
socket
.
on
(
'
disconnect
'
,
function
()
{
output
(
'
<span class="disconnect-msg">The client has disconnected!</span>
'
);
});
function
sendDisconnect
()
{
socket
.
disconnect
();
}
function
sendMessage
()
{
var
message
=
$
(
'
#msg
'
).
val
();
$
(
'
#msg
'
).
val
(
''
);
socket
.
emit
(
'
chatevent
'
,
{
userName
:
userName
,
message
:
message
});
}
function
output
(
message
)
{
var
currentTime
=
"
<span class='time'>
"
+
moment
().
format
(
'
HH:mm:ss.SSS
'
)
+
"
</span>
"
;
var
element
=
$
(
"
<div>
"
+
currentTime
+
"
"
+
message
+
"
</div>
"
);
$
(
'
#console
'
).
prepend
(
element
);
}
$
(
document
).
keydown
(
function
(
e
){
if
(
e
.
keyCode
==
13
)
{
$
(
'
#send
'
).
click
();
}
});
</script>
</head>
<body>
<h1>
Netty-socketio Demo Chat
</h1>
<br/>
<div
id=
"console"
class=
"well"
>
</div>
<form
class=
"well form-inline"
onsubmit=
"return false;"
>
<input
id=
"msg"
class=
"input-xlarge"
type=
"text"
placeholder=
"Type something..."
/>
<button
type=
"button"
onClick=
"sendMessage()"
class=
"btn"
id=
"send"
>
Send
</button>
<button
type=
"button"
onClick=
"sendDisconnect()"
class=
"btn"
>
Disconnect
</button>
</form>
</body>
</html>
zheng-message/zheng-message-client/index.html
浏览文件 @
a8e1bab2
<!DOCTYPE html>
<html
lang=
"zh-CN"
xmlns:th=
"http://www.thymeleaf.org"
>
<html>
<head>
<meta
charset=
"UTF-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<title>
实时推送系统前端示例
</title>
<style>
#main
{
width
:
100%
;
height
:
400px
;
margin
:
0
auto
;}
.namespace
{
width
:
100%
;
height
:
400px
;
background
:
#000
;}
.title
{
width
:
100%
;
height
:
40px
;
font-size
:
0
;
background
:
#666
;}
.input
,
.button
{
float
:
left
;
height
:
40px
;
border
:
none
;
background
:
none
;
outline
:
none
;
color
:
#fff
;}
.input
{
width
:
25%
;
text-indent
:
10px
;
font-weight
:
bold
;}
.button
{
width
:
10%
;
cursor
:
pointer
;}
#token
{
width
:
20%
;}
#env
{
background
:
rgb
(
194
,
53
,
49
);}
.messages
{
width
:
100%
;
height
:
340px
;
overflow-y
:
auto
;
font-size
:
12px
;
line-height
:
2em
;
color
:
#fff
;}
.messages
li
{
list-style-type
:
none
;}
.messages
.connect
{
color
:
#00cc00
;}
.messages
.warn
{
color
:
#cccc00
;}
.messages
.disconnect
{
color
:
#cc0000
;}
table
{
width
:
100%
;
border-collapse
:
collapse
;
border
:
solid
#ccc
;
border-width
:
1px
0
0
1px
}
table
th
,
table
td
{
border
:
solid
#ccc
;
border-width
:
0
1px
1px
0
;
padding
:
14px
;
text-align
:
center
}
</style>
</head>
<body>
<div
id=
"main"
>
<div
class=
"namespace"
>
<div
class=
"title"
>
<select
id=
"env"
class=
"input"
>
<option
value=
"http://localhost:8882"
>
开发环境
</option>
</select>
<input
id=
"namespace"
class=
"input"
type=
"text"
placeholder=
"namespace"
value=
""
/>
<input
id=
"token"
class=
"input"
type=
"text"
placeholder=
"token"
value=
""
/>
<input
id=
"connect"
class=
"button"
type=
"button"
value=
"连接"
/>
<input
id=
"send"
class=
"button"
type=
"button"
value=
"发言"
/>
<input
id=
"disconnect"
class=
"button"
type=
"button"
value=
"断开"
/>
</div>
<div
class=
"messages"
>
<ul
id=
"list"
>
</ul>
</div>
</div>
</div>
<script
src=
"https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"
></script>
<script
src=
"https://cdn.bootcss.com/socket.io/2.1.1/socket.io.js"
></script>
<script
type=
"text/javascript"
>
$
(
function
()
{
// SocketIO客户端
var
socket
;
$
(
'
#connect
'
).
click
(
function
()
{
// 获取token,请求业务系统接口
var
token
=
$
(
'
#token
'
).
val
();
// 创建socketio连接
socket
=
io
.
connect
(
$
(
'
#env
'
).
val
()
+
$
(
'
#namespace
'
).
val
()
+
'
?token=
'
+
token
);
socket
.
on
(
'
connect
'
,
function
()
{
$
(
'
#list
'
).
prepend
(
'
<li class="connect">已连接服务器!</li>
'
);
});
socket
.
on
(
'
message
'
,
function
(
data
,
ackServerCallback
)
{
$
(
'
#list
'
).
prepend
(
'
<li class="data">收到服务器消息:
'
+
JSON
.
stringify
(
data
)
+
'
</li>
'
);
if
(
ackServerCallback
)
{
ackServerCallback
();
<meta
charset=
"utf-8"
/>
<title>
Demo Chat
</title>
<link
href=
"bootstrap.css"
rel=
"stylesheet"
>
<style>
body
{
padding
:
20px
;
}
#console
{
height
:
400px
;
overflow
:
auto
;
}
.username-msg
{
color
:
orange
;}
.connect-msg
{
color
:
green
;}
.disconnect-msg
{
color
:
red
;}
.send-msg
{
color
:
#888
}
</style>
<script
src=
"js/socket.io/socket.io.js"
></script>
<script
src=
"js/moment.min.js"
></script>
<script
src=
"http://code.jquery.com/jquery-1.10.1.min.js"
></script>
<script>
var
userName
=
'
user
'
+
Math
.
floor
((
Math
.
random
()
*
1000
)
+
1
);
var
socket
=
io
.
connect
(
'
http://localhost:9092
'
);
socket
.
on
(
'
connect
'
,
function
()
{
output
(
'
<span class="connect-msg">Client has connected to the server!</span>
'
);
});
socket
.
on
(
'
chatevent
'
,
function
(
data
)
{
output
(
'
<span class="username-msg">
'
+
data
.
userName
+
'
:</span>
'
+
data
.
message
);
});
socket
.
on
(
'
disconnect
'
,
function
()
{
output
(
'
<span class="disconnect-msg">The client has disconnected!</span>
'
);
});
function
sendDisconnect
()
{
socket
.
disconnect
();
}
});
socket
.
on
(
'
connect_error
'
,
function
(
error
)
{
$
(
'
#list
'
).
prepend
(
'
<li class="warn">连接服务器失败!</li>
'
);
console
.
log
(
error
);
});
socket
.
on
(
'
disconnect
'
,
function
()
{
$
(
'
#list
'
).
prepend
(
'
<li class="disconnect">已断开服务器!</li>
'
);
});
$
(
'
#send
'
).
click
(
function
()
{
socket
.
emit
(
'
message
'
,
{
userName
:
'
userName
'
,
message
:
new
Date
()});
});
$
(
'
#disconnect
'
).
click
(
function
()
{
socket
.
close
();
});
// 防止重复连接
$
(
this
).
attr
(
'
disabled
'
,
'
disabled
'
);
function
sendMessage
()
{
var
message
=
$
(
'
#msg
'
).
val
();
$
(
'
#msg
'
).
val
(
''
);
var
jsonObject
=
{
userName
:
userName
,
message
:
message
};
socket
.
emit
(
'
chatevent
'
,
jsonObject
);
}
function
output
(
message
)
{
var
currentTime
=
"
<span class='time'>
"
+
moment
().
format
(
'
HH:mm:ss.SSS
'
)
+
"
</span>
"
;
var
element
=
$
(
"
<div>
"
+
currentTime
+
"
"
+
message
+
"
</div>
"
);
$
(
'
#console
'
).
prepend
(
element
);
}
$
(
document
).
keydown
(
function
(
e
){
if
(
e
.
keyCode
==
13
)
{
$
(
'
#send
'
).
click
();
}
});
});
</script>
</script>
</head>
<body>
<h1>
Netty-socketio Demo Chat
</h1>
<br/>
<div
id=
"console"
class=
"well"
>
</div>
<form
class=
"well form-inline"
onsubmit=
"return false;"
>
<input
id=
"msg"
class=
"input-xlarge"
type=
"text"
placeholder=
"Type something..."
/>
<button
type=
"button"
onClick=
"sendMessage()"
class=
"btn"
id=
"send"
>
Send
</button>
<button
type=
"button"
onClick=
"sendDisconnect()"
class=
"btn"
>
Disconnect
</button>
</form>
</body>
</html>
\ No newline at end of file
</html>
zheng-message/zheng-message-client/js/jquery-1.7.2.min.js
0 → 100644
浏览文件 @
a8e1bab2
此差异已折叠。
点击以展开。
zheng-message/zheng-message-client/js/moment.min.js
0 → 100644
浏览文件 @
a8e1bab2
// moment.js
// version : 1.6.2
// author : Tim Wood
// license : MIT
// momentjs.com
(
function
(
a
,
b
){
function
A
(
a
,
b
){
this
.
_d
=
a
,
this
.
_isUTC
=!!
b
}
function
B
(
a
){
return
a
<
0
?
Math
.
ceil
(
a
):
Math
.
floor
(
a
)}
function
C
(
a
){
var
b
=
this
.
_data
=
{},
c
=
a
.
years
||
a
.
y
||
0
,
d
=
a
.
months
||
a
.
M
||
0
,
e
=
a
.
weeks
||
a
.
w
||
0
,
f
=
a
.
days
||
a
.
d
||
0
,
g
=
a
.
hours
||
a
.
h
||
0
,
h
=
a
.
minutes
||
a
.
m
||
0
,
i
=
a
.
seconds
||
a
.
s
||
0
,
j
=
a
.
milliseconds
||
a
.
ms
||
0
;
this
.
_milliseconds
=
j
+
i
*
1
e3
+
h
*
6
e4
+
g
*
36
e5
,
this
.
_days
=
f
+
e
*
7
,
this
.
_months
=
d
+
c
*
12
,
b
.
milliseconds
=
j
%
1
e3
,
i
+=
B
(
j
/
1
e3
),
b
.
seconds
=
i
%
60
,
h
+=
B
(
i
/
60
),
b
.
minutes
=
h
%
60
,
g
+=
B
(
h
/
60
),
b
.
hours
=
g
%
24
,
f
+=
B
(
g
/
24
),
f
+=
e
*
7
,
b
.
days
=
f
%
30
,
d
+=
B
(
f
/
30
),
b
.
months
=
d
%
12
,
c
+=
B
(
d
/
12
),
b
.
years
=
c
}
function
D
(
a
,
b
){
var
c
=
a
+
""
;
while
(
c
.
length
<
b
)
c
=
"
0
"
+
c
;
return
c
}
function
E
(
a
,
b
,
c
){
var
d
=
b
.
_milliseconds
,
e
=
b
.
_days
,
f
=
b
.
_months
,
g
;
d
&&
a
.
_d
.
setTime
(
+
a
+
d
*
c
),
e
&&
a
.
date
(
a
.
date
()
+
e
*
c
),
f
&&
(
g
=
a
.
date
(),
a
.
date
(
1
).
month
(
a
.
month
()
+
f
*
c
).
date
(
Math
.
min
(
g
,
a
.
daysInMonth
())))}
function
F
(
a
){
return
Object
.
prototype
.
toString
.
call
(
a
)
===
"
[object Array]
"
}
function
G
(
b
){
return
new
a
(
b
[
0
],
b
[
1
]
||
0
,
b
[
2
]
||
1
,
b
[
3
]
||
0
,
b
[
4
]
||
0
,
b
[
5
]
||
0
,
b
[
6
]
||
0
)}
function
H
(
b
,
d
){
function
q
(
d
){
var
l
,
r
;
switch
(
d
){
case
"
M
"
:
return
e
+
1
;
case
"
Mo
"
:
return
e
+
1
+
o
(
e
+
1
);
case
"
MM
"
:
return
D
(
e
+
1
,
2
);
case
"
MMM
"
:
return
c
.
monthsShort
[
e
];
case
"
MMMM
"
:
return
c
.
months
[
e
];
case
"
D
"
:
return
f
;
case
"
Do
"
:
return
f
+
o
(
f
);
case
"
DD
"
:
return
D
(
f
,
2
);
case
"
DDD
"
:
return
l
=
new
a
(
g
,
e
,
f
),
r
=
new
a
(
g
,
0
,
1
),
~~
((
l
-
r
)
/
864
e5
+
1.5
);
case
"
DDDo
"
:
return
l
=
q
(
"
DDD
"
),
l
+
o
(
l
);
case
"
DDDD
"
:
return
D
(
q
(
"
DDD
"
),
3
);
case
"
d
"
:
return
h
;
case
"
do
"
:
return
h
+
o
(
h
);
case
"
ddd
"
:
return
c
.
weekdaysShort
[
h
];
case
"
dddd
"
:
return
c
.
weekdays
[
h
];
case
"
w
"
:
return
l
=
new
a
(
g
,
e
,
f
-
h
+
5
),
r
=
new
a
(
l
.
getFullYear
(),
0
,
4
),
~~
((
l
-
r
)
/
864
e5
/
7
+
1.5
);
case
"
wo
"
:
return
l
=
q
(
"
w
"
),
l
+
o
(
l
);
case
"
ww
"
:
return
D
(
q
(
"
w
"
),
2
);
case
"
YY
"
:
return
D
(
g
%
100
,
2
);
case
"
YYYY
"
:
return
g
;
case
"
a
"
:
return
p
?
p
(
i
,
j
,
!
1
):
i
>
11
?
"
pm
"
:
"
am
"
;
case
"
A
"
:
return
p
?
p
(
i
,
j
,
!
0
):
i
>
11
?
"
PM
"
:
"
AM
"
;
case
"
H
"
:
return
i
;
case
"
HH
"
:
return
D
(
i
,
2
);
case
"
h
"
:
return
i
%
12
||
12
;
case
"
hh
"
:
return
D
(
i
%
12
||
12
,
2
);
case
"
m
"
:
return
j
;
case
"
mm
"
:
return
D
(
j
,
2
);
case
"
s
"
:
return
k
;
case
"
ss
"
:
return
D
(
k
,
2
);
case
"
S
"
:
return
~~
(
m
/
100
);
case
"
SS
"
:
return
D
(
~~
(
m
/
10
),
2
);
case
"
SSS
"
:
return
D
(
m
,
3
);
case
"
Z
"
:
return
(
n
<
0
?
"
-
"
:
"
+
"
)
+
D
(
~~
(
Math
.
abs
(
n
)
/
60
),
2
)
+
"
:
"
+
D
(
~~
(
Math
.
abs
(
n
)
%
60
),
2
);
case
"
ZZ
"
:
return
(
n
<
0
?
"
-
"
:
"
+
"
)
+
D
(
~~
(
10
*
Math
.
abs
(
n
)
/
6
),
4
);
case
"
L
"
:
case
"
LL
"
:
case
"
LLL
"
:
case
"
LLLL
"
:
case
"
LT
"
:
return
H
(
b
,
c
.
longDateFormat
[
d
]);
default
:
return
d
.
replace
(
/
(
^
\[)
|
(\\)
|
\]
$/g
,
""
)}}
var
e
=
b
.
month
(),
f
=
b
.
date
(),
g
=
b
.
year
(),
h
=
b
.
day
(),
i
=
b
.
hours
(),
j
=
b
.
minutes
(),
k
=
b
.
seconds
(),
m
=
b
.
milliseconds
(),
n
=-
b
.
zone
(),
o
=
c
.
ordinal
,
p
=
c
.
meridiem
;
return
d
.
replace
(
l
,
q
)}
function
I
(
a
){
switch
(
a
){
case
"
DDDD
"
:
return
p
;
case
"
YYYY
"
:
return
q
;
case
"
S
"
:
case
"
SS
"
:
case
"
SSS
"
:
case
"
DDD
"
:
return
o
;
case
"
MMM
"
:
case
"
MMMM
"
:
case
"
ddd
"
:
case
"
dddd
"
:
case
"
a
"
:
case
"
A
"
:
return
r
;
case
"
Z
"
:
case
"
ZZ
"
:
return
s
;
case
"
T
"
:
return
t
;
case
"
MM
"
:
case
"
DD
"
:
case
"
dd
"
:
case
"
YY
"
:
case
"
HH
"
:
case
"
hh
"
:
case
"
mm
"
:
case
"
ss
"
:
case
"
M
"
:
case
"
D
"
:
case
"
d
"
:
case
"
H
"
:
case
"
h
"
:
case
"
m
"
:
case
"
s
"
:
return
n
;
default
:
return
new
RegExp
(
a
.
replace
(
"
\\
"
,
""
))}}
function
J
(
a
,
b
,
d
,
e
){
var
f
;
switch
(
a
){
case
"
M
"
:
case
"
MM
"
:
d
[
1
]
=
b
==
null
?
0
:
~~
b
-
1
;
break
;
case
"
MMM
"
:
case
"
MMMM
"
:
for
(
f
=
0
;
f
<
12
;
f
++
)
if
(
c
.
monthsParse
[
f
].
test
(
b
)){
d
[
1
]
=
f
;
break
}
break
;
case
"
D
"
:
case
"
DD
"
:
case
"
DDD
"
:
case
"
DDDD
"
:
d
[
2
]
=~~
b
;
break
;
case
"
YY
"
:
b
=~~
b
,
d
[
0
]
=
b
+
(
b
>
70
?
1900
:
2
e3
);
break
;
case
"
YYYY
"
:
d
[
0
]
=~~
Math
.
abs
(
b
);
break
;
case
"
a
"
:
case
"
A
"
:
e
.
isPm
=
(
b
+
""
).
toLowerCase
()
===
"
pm
"
;
break
;
case
"
H
"
:
case
"
HH
"
:
case
"
h
"
:
case
"
hh
"
:
d
[
3
]
=~~
b
;
break
;
case
"
m
"
:
case
"
mm
"
:
d
[
4
]
=~~
b
;
break
;
case
"
s
"
:
case
"
ss
"
:
d
[
5
]
=~~
b
;
break
;
case
"
S
"
:
case
"
SS
"
:
case
"
SSS
"
:
d
[
6
]
=~~
((
"
0.
"
+
b
)
*
1
e3
);
break
;
case
"
Z
"
:
case
"
ZZ
"
:
e
.
isUTC
=!
0
,
f
=
(
b
+
""
).
match
(
x
),
f
&&
f
[
1
]
&&
(
e
.
tzh
=~~
f
[
1
]),
f
&&
f
[
2
]
&&
(
e
.
tzm
=~~
f
[
2
]),
f
&&
f
[
0
]
===
"
+
"
&&
(
e
.
tzh
=-
e
.
tzh
,
e
.
tzm
=-
e
.
tzm
)}}
function
K
(
b
,
c
){
var
d
=
[
0
,
0
,
1
,
0
,
0
,
0
,
0
],
e
=
{
tzh
:
0
,
tzm
:
0
},
f
=
c
.
match
(
l
),
g
,
h
;
for
(
g
=
0
;
g
<
f
.
length
;
g
++
)
h
=
(
I
(
f
[
g
]).
exec
(
b
)
||
[])[
0
],
b
=
b
.
replace
(
I
(
f
[
g
]),
""
),
J
(
f
[
g
],
h
,
d
,
e
);
return
e
.
isPm
&&
d
[
3
]
<
12
&&
(
d
[
3
]
+=
12
),
e
.
isPm
===!
1
&&
d
[
3
]
===
12
&&
(
d
[
3
]
=
0
),
d
[
3
]
+=
e
.
tzh
,
d
[
4
]
+=
e
.
tzm
,
e
.
isUTC
?
new
a
(
a
.
UTC
.
apply
({},
d
)):
G
(
d
)}
function
L
(
a
,
b
){
var
c
=
Math
.
min
(
a
.
length
,
b
.
length
),
d
=
Math
.
abs
(
a
.
length
-
b
.
length
),
e
=
0
,
f
;
for
(
f
=
0
;
f
<
c
;
f
++
)
~~
a
[
f
]
!==~~
b
[
f
]
&&
e
++
;
return
e
+
d
}
function
M
(
a
,
b
){
var
c
,
d
=
a
.
match
(
m
)
||
[],
e
,
f
=
99
,
g
,
h
,
i
;
for
(
g
=
0
;
g
<
b
.
length
;
g
++
)
h
=
K
(
a
,
b
[
g
]),
e
=
H
(
new
A
(
h
),
b
[
g
]).
match
(
m
)
||
[],
i
=
L
(
d
,
e
),
i
<
f
&&
(
f
=
i
,
c
=
h
);
return
c
}
function
N
(
b
){
var
c
=
"
YYYY-MM-DDT
"
,
d
;
if
(
u
.
exec
(
b
)){
for
(
d
=
0
;
d
<
4
;
d
++
)
if
(
w
[
d
][
1
].
exec
(
b
)){
c
+=
w
[
d
][
0
];
break
}
return
s
.
exec
(
b
)?
K
(
b
,
c
+
"
Z
"
):
K
(
b
,
c
)}
return
new
a
(
b
)}
function
O
(
a
,
b
,
d
,
e
){
var
f
=
c
.
relativeTime
[
a
];
return
typeof
f
==
"
function
"
?
f
(
b
||
1
,
!!
d
,
a
,
e
):
f
.
replace
(
/%d/i
,
b
||
1
)}
function
P
(
a
,
b
){
var
c
=
e
(
Math
.
abs
(
a
)
/
1
e3
),
d
=
e
(
c
/
60
),
f
=
e
(
d
/
60
),
g
=
e
(
f
/
24
),
h
=
e
(
g
/
365
),
i
=
c
<
45
&&
[
"
s
"
,
c
]
||
d
===
1
&&
[
"
m
"
]
||
d
<
45
&&
[
"
mm
"
,
d
]
||
f
===
1
&&
[
"
h
"
]
||
f
<
22
&&
[
"
hh
"
,
f
]
||
g
===
1
&&
[
"
d
"
]
||
g
<=
25
&&
[
"
dd
"
,
g
]
||
g
<=
45
&&
[
"
M
"
]
||
g
<
345
&&
[
"
MM
"
,
e
(
g
/
30
)]
||
h
===
1
&&
[
"
y
"
]
||
[
"
yy
"
,
h
];
return
i
[
2
]
=
b
,
i
[
3
]
=
a
>
0
,
O
.
apply
({},
i
)}
function
Q
(
a
,
b
){
c
.
fn
[
a
]
=
function
(
a
){
var
c
=
this
.
_isUTC
?
"
UTC
"
:
""
;
return
a
!=
null
?(
this
.
_d
[
"
set
"
+
c
+
b
](
a
),
this
):
this
.
_d
[
"
get
"
+
c
+
b
]()}}
function
R
(
a
){
c
.
duration
.
fn
[
a
]
=
function
(){
return
this
.
_data
[
a
]}}
function
S
(
a
,
b
){
c
.
duration
.
fn
[
"
as
"
+
a
]
=
function
(){
return
+
this
/b}}var c,d="1.6.2",e=Math.round,f,g={},h="en",i=typeof module!="undefined",j="months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem".split
(
"|"
)
,k=/
^
\
/
?
Date
\
((
\
-
?
\
d
+
)
/
i
,
l
=
/
(\[[^\[]
*
\])
|
(\\)?(
Mo|MM
?
M
?
M
?
|Do|DDDo|DD
?
D
?
D
?
|dddd
?
|do
?
|w
[
o|w
]?
|YYYY|YY|a|A|hh
?
|HH
?
|mm
?
|ss
?
|SS
?
S
?
|zz
?
|ZZ
?
|LT|LL
?
L
?
L
?)
/g
,
m
=
/
([
0-9a-zA-Z
\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
]
+
)
/gi
,
n
=
/
\d\d?
/
,
o
=
/
\d{1,3}
/
,
p
=
/
\d{3}
/
,
q
=
/
\d{4}
/
,
r
=
/
[
0-9a-z
\u
00A0-
\u
D7FF
\u
F900-
\u
FDCF
\u
FDF0-
\u
FFEF
]
+/i
,
s
=
/Z|
[\+\-]\d\d
:
?\d\d
/i
,
t
=
/T/i
,
u
=
/^
\s
*
\d{4}
-
\d\d
-
\d\d(
T
(\d\d(
:
\d\d(
:
\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d
:
?\d\d)?)?
/
,
v
=
"
YYYY-MM-DDTHH:mm:ssZ
"
,
w
=
[[
"
HH:mm:ss.S
"
,
/T
\d\d
:
\d\d
:
\d\d\.\d{1,3}
/
],[
"
HH:mm:ss
"
,
/T
\d\d
:
\d\d
:
\d\d
/
],[
"
HH:mm
"
,
/T
\d\d
:
\d\d
/
],[
"
HH
"
,
/T
\d\d
/
]],
x
=
/
([\+\-]
|
\d\d)
/gi
,
y
=
"
Month|Date|Hours|Minutes|Seconds|Milliseconds
"
.
split
(
"
|
"
),
z
=
{
Milliseconds
:
1
,
Seconds
:
1
e3
,
Minutes
:
6
e4
,
Hours
:
36
e5
,
Days
:
864
e5
,
Months
:
2592
e6
,
Years
:
31536
e6
};
c
=
function
(
d
,
e
){
if
(
d
===
null
||
d
===
""
)
return
null
;
var
f
,
g
,
h
;
return
c
.
isMoment
(
d
)?(
f
=
new
a
(
+
d
.
_d
),
h
=
d
.
_isUTC
):
e
?
F
(
e
)?
f
=
M
(
d
,
e
):
f
=
K
(
d
,
e
):(
g
=
k
.
exec
(
d
),
f
=
d
===
b
?
new
a
:
g
?
new
a
(
+
g
[
1
]):
d
instanceof
a
?
d
:
F
(
d
)?
G
(
d
):
typeof
d
==
"
string
"
?
N
(
d
):
new
a
(
d
)),
new
A
(
f
,
h
)},
c
.
utc
=
function
(
b
,
d
){
return
F
(
b
)?
new
A
(
new
a
(
a
.
UTC
.
apply
({},
b
)),
!
0
):
d
&&
b
?
c
(
b
+
"
+0000
"
,
d
+
"
Z
"
).
utc
():
c
(
b
&&!
s
.
exec
(
b
)?
b
+
"
+0000
"
:
b
).
utc
()},
c
.
unix
=
function
(
a
){
return
c
(
a
*
1
e3
)},
c
.
duration
=
function
(
a
,
b
){
var
d
=
c
.
isDuration
(
a
),
e
=
typeof
a
==
"
number
"
,
f
=
d
?
a
.
_data
:
e
?{}:
a
;
return
e
&&
(
b
?
f
[
b
]
=
a
:
f
.
milliseconds
=
a
),
new
C
(
f
)},
c
.
humanizeDuration
=
function
(
a
,
b
,
d
){
return
c
.
duration
(
a
,
b
===!
0
?
null
:
b
).
humanize
(
b
===!
0
?
!
0
:
d
)},
c
.
version
=
d
,
c
.
defaultFormat
=
v
,
c
.
lang
=
function
(
a
,
b
){
var
d
,
e
,
f
=
[];
if
(
!
a
)
return
h
;
if
(
b
){
for
(
d
=
0
;
d
<
12
;
d
++
)
f
[
d
]
=
new
RegExp
(
"
^
"
+
b
.
months
[
d
]
+
"
|^
"
+
b
.
monthsShort
[
d
].
replace
(
"
.
"
,
""
),
"
i
"
);
b
.
monthsParse
=
b
.
monthsParse
||
f
,
g
[
a
]
=
b
}
if
(
g
[
a
]){
for
(
d
=
0
;
d
<
j
.
length
;
d
++
)
c
[
j
[
d
]]
=
g
[
a
][
j
[
d
]]
||
g
.
en
[
j
[
d
]];
h
=
a
}
else
i
&&
(
e
=
require
(
"
./lang/
"
+
a
),
c
.
lang
(
a
,
e
))},
c
.
lang
(
"
en
"
,{
months
:
"
January_February_March_April_May_June_July_August_September_October_November_December
"
.
split
(
"
_
"
),
monthsShort
:
"
Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec
"
.
split
(
"
_
"
),
weekdays
:
"
Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday
"
.
split
(
"
_
"
),
weekdaysShort
:
"
Sun_Mon_Tue_Wed_Thu_Fri_Sat
"
.
split
(
"
_
"
),
longDateFormat
:{
LT
:
"
h:mm A
"
,
L
:
"
MM/DD/YYYY
"
,
LL
:
"
MMMM D YYYY
"
,
LLL
:
"
MMMM D YYYY LT
"
,
LLLL
:
"
dddd, MMMM D YYYY LT
"
},
meridiem
:
!
1
,
calendar
:{
sameDay
:
"
[Today at] LT
"
,
nextDay
:
"
[Tomorrow at] LT
"
,
nextWeek
:
"
dddd [at] LT
"
,
lastDay
:
"
[Yesterday at] LT
"
,
lastWeek
:
"
[last] dddd [at] LT
"
,
sameElse
:
"
L
"
},
relativeTime
:{
future
:
"
in %s
"
,
past
:
"
%s ago
"
,
s
:
"
a few seconds
"
,
m
:
"
a minute
"
,
mm
:
"
%d minutes
"
,
h
:
"
an hour
"
,
hh
:
"
%d hours
"
,
d
:
"
a day
"
,
dd
:
"
%d days
"
,
M
:
"
a month
"
,
MM
:
"
%d months
"
,
y
:
"
a year
"
,
yy
:
"
%d years
"
},
ordinal
:
function
(
a
){
var
b
=
a
%
10
;
return
~~
(
a
%
100
/
10
)
===
1
?
"
th
"
:
b
===
1
?
"
st
"
:
b
===
2
?
"
nd
"
:
b
===
3
?
"
rd
"
:
"
th
"
}}),
c
.
isMoment
=
function
(
a
){
return
a
instanceof
A
},
c
.
isDuration
=
function
(
a
){
return
a
instanceof
C
},
c
.
fn
=
A
.
prototype
=
{
clone
:
function
(){
return
c
(
this
)},
valueOf
:
function
(){
return
+
this
.
_d
},
unix
:
function
(){
return
Math
.
floor
(
+
this
.
_d
/
1
e3
)},
toString
:
function
(){
return
this
.
_d
.
toString
()},
toDate
:
function
(){
return
this
.
_d
},
utc
:
function
(){
return
this
.
_isUTC
=!
0
,
this
},
local
:
function
(){
return
this
.
_isUTC
=!
1
,
this
},
format
:
function
(
a
){
return
H
(
this
,
a
?
a
:
c
.
defaultFormat
)},
add
:
function
(
a
,
b
){
var
d
=
b
?
c
.
duration
(
+
b
,
a
):
c
.
duration
(
a
);
return
E
(
this
,
d
,
1
),
this
},
subtract
:
function
(
a
,
b
){
var
d
=
b
?
c
.
duration
(
+
b
,
a
):
c
.
duration
(
a
);
return
E
(
this
,
d
,
-
1
),
this
},
diff
:
function
(
a
,
b
,
d
){
var
f
=
this
.
_isUTC
?
c
(
a
).
utc
():
c
(
a
).
local
(),
g
=
(
this
.
zone
()
-
f
.
zone
())
*
6
e4
,
h
=
this
.
_d
-
f
.
_d
-
g
,
i
=
this
.
year
()
-
f
.
year
(),
j
=
this
.
month
()
-
f
.
month
(),
k
=
this
.
date
()
-
f
.
date
(),
l
;
return
b
===
"
months
"
?
l
=
i
*
12
+
j
+
k
/
30
:
b
===
"
years
"
?
l
=
i
+
(
j
+
k
/
30
)
/
12
:
l
=
b
===
"
seconds
"
?
h
/
1
e3
:
b
===
"
minutes
"
?
h
/
6
e4
:
b
===
"
hours
"
?
h
/
36
e5
:
b
===
"
days
"
?
h
/
864
e5
:
b
===
"
weeks
"
?
h
/
6048
e5
:
h
,
d
?
l
:
e
(
l
)},
from
:
function
(
a
,
b
){
return
c
.
duration
(
this
.
diff
(
a
)).
humanize
(
!
b
)},
fromNow
:
function
(
a
){
return
this
.
from
(
c
(),
a
)},
calendar
:
function
(){
var
a
=
this
.
diff
(
c
().
sod
(),
"
days
"
,
!
0
),
b
=
c
.
calendar
,
d
=
b
.
sameElse
,
e
=
a
<-
6
?
d
:
a
<-
1
?
b
.
lastWeek
:
a
<
0
?
b
.
lastDay
:
a
<
1
?
b
.
sameDay
:
a
<
2
?
b
.
nextDay
:
a
<
7
?
b
.
nextWeek
:
d
;
return
this
.
format
(
typeof
e
==
"
function
"
?
e
.
apply
(
this
):
e
)},
isLeapYear
:
function
(){
var
a
=
this
.
year
();
return
a
%
4
===
0
&&
a
%
100
!==
0
||
a
%
400
===
0
},
isDST
:
function
(){
return
this
.
zone
()
<
c
([
this
.
year
()]).
zone
()
||
this
.
zone
()
<
c
([
this
.
year
(),
5
]).
zone
()},
day
:
function
(
a
){
var
b
=
this
.
_isUTC
?
this
.
_d
.
getUTCDay
():
this
.
_d
.
getDay
();
return
a
==
null
?
b
:
this
.
add
({
d
:
a
-
b
})},
sod
:
function
(){
return
c
(
this
).
hours
(
0
).
minutes
(
0
).
seconds
(
0
).
milliseconds
(
0
)},
eod
:
function
(){
return
this
.
sod
().
add
({
d
:
1
,
ms
:
-
1
})},
zone
:
function
(){
return
this
.
_isUTC
?
0
:
this
.
_d
.
getTimezoneOffset
()},
daysInMonth
:
function
(){
return
c
(
this
).
month
(
this
.
month
()
+
1
).
date
(
0
).
date
()}};
for
(
f
=
0
;
f
<
y
.
length
;
f
++
)
Q
(
y
[
f
].
toLowerCase
(),
y
[
f
]);
Q
(
"
year
"
,
"
FullYear
"
),
c
.
duration
.
fn
=
C
.
prototype
=
{
weeks
:
function
(){
return
B
(
this
.
days
()
/
7
)},
valueOf
:
function
(){
return
this
.
_milliseconds
+
this
.
_days
*
864
e5
+
this
.
_months
*
2592
e6
},
humanize
:
function
(
a
){
var
b
=+
this
,
d
=
c
.
relativeTime
,
e
=
P
(
b
,
!
a
);
return
a
&&
(
e
=
(
b
<=
0
?
d
.
past
:
d
.
future
).
replace
(
/%s/i
,
e
)),
e
}};
for
(
f
in
z
)
z
.
hasOwnProperty
(
f
)
&&
(
S
(
f
,
z
[
f
]),
R
(
f
.
toLowerCase
()));
S
(
"
Weeks
"
,
6048
e5
),
i
&&
(
module
.
exports
=
c
),
typeof
window
!=
"
undefined
"
&&
typeof
ender
==
"
undefined
"
&&
(
window
.
moment
=
c
),
typeof
define
==
"
function
"
&&
define
.
amd
&&
define
(
"
moment
"
,[],
function
(){
return
c
})})(
Date
);
\ No newline at end of file
zheng-message/zheng-message-client/js/socket.io/socket.io.js
0 → 100644
浏览文件 @
a8e1bab2
此差异已折叠。
点击以展开。
zheng-message/zheng-message-client/namespace-index.html
0 → 100644
浏览文件 @
a8e1bab2
<!DOCTYPE html>
<html>
<head>
<title>
Demo Chat
</title>
<link
href=
"bootstrap.css"
rel=
"stylesheet"
>
<style>
body
{
padding
:
20px
;
}
.console
{
height
:
400px
;
overflow
:
auto
;
}
.username-msg
{
color
:
orange
;}
.connect-msg
{
color
:
green
;}
.disconnect-msg
{
color
:
red
;}
.send-msg
{
color
:
#888
}
</style>
<script
src=
"js/socket.io/socket.io.js"
></script>
<script
src=
"js/moment.min.js"
></script>
<script
src=
"http://code.jquery.com/jquery-1.10.1.min.js"
></script>
<script>
var
userName1
=
'
user1_
'
+
Math
.
floor
((
Math
.
random
()
*
1000
)
+
1
);
var
userName2
=
'
user2_
'
+
Math
.
floor
((
Math
.
random
()
*
1000
)
+
1
);
var
chat1Socket
=
io
.
connect
(
'
http://localhost:9092/chat1
'
);
var
chat2Socket
=
io
.
connect
(
'
http://localhost:9092/chat2
'
);
function
connectHandler
(
parentId
)
{
return
function
()
{
output
(
'
<span class="connect-msg">Client has connected to the server!</span>
'
,
parentId
);
}
}
function
messageHandler
(
parentId
)
{
return
function
(
data
)
{
output
(
'
<span class="username-msg">
'
+
data
.
userName
+
'
:</span>
'
+
data
.
message
,
parentId
);
}
}
function
disconnectHandler
(
parentId
)
{
return
function
()
{
output
(
'
<span class="disconnect-msg">The client has disconnected!</span>
'
,
parentId
);
}
}
function
sendMessageHandler
(
parentId
,
userName
,
chatSocket
)
{
var
message
=
$
(
parentId
+
'
.msg
'
).
val
();
$
(
parentId
+
'
.msg
'
).
val
(
''
);
var
jsonObject
=
{
'
@class
'
:
'
com.corundumstudio.socketio.demo.ChatObject
'
,
userName
:
userName
,
message
:
message
};
chatSocket
.
json
.
send
(
jsonObject
);
}
chat1Socket
.
on
(
'
connect
'
,
connectHandler
(
'
#chat1
'
));
chat2Socket
.
on
(
'
connect
'
,
connectHandler
(
'
#chat2
'
));
chat1Socket
.
on
(
'
message
'
,
messageHandler
(
'
#chat1
'
));
chat2Socket
.
on
(
'
message
'
,
messageHandler
(
'
#chat2
'
));
chat1Socket
.
on
(
'
disconnect
'
,
disconnectHandler
(
'
#chat1
'
));
chat2Socket
.
on
(
'
disconnect
'
,
disconnectHandler
(
'
#chat2
'
));
function
sendDisconnect1
()
{
chat1Socket
.
disconnect
();
}
function
sendDisconnect2
()
{
chat2Socket
.
disconnect
();
}
function
sendMessage1
()
{
sendMessageHandler
(
'
#chat1
'
,
userName1
,
chat1Socket
);
}
function
sendMessage2
()
{
sendMessageHandler
(
'
#chat2
'
,
userName2
,
chat2Socket
);
}
function
output
(
message
,
parentId
)
{
var
currentTime
=
"
<span class='time'>
"
+
moment
().
format
(
'
HH:mm:ss.SSS
'
)
+
"
</span>
"
;
var
element
=
$
(
"
<div>
"
+
currentTime
+
"
"
+
message
+
"
</div>
"
);
$
(
parentId
+
'
.console
'
).
prepend
(
element
);
}
$
(
document
).
keydown
(
function
(
e
){
if
(
e
.
keyCode
==
13
)
{
$
(
'
#send
'
).
click
();
}
});
</script>
</head>
<body>
<h1>
Namespaces demo chat
</h1>
<br/>
<div
id=
"chat1"
style=
"width: 49%; float: left;"
>
<h4>
chat1
</h4>
<div
class=
"console well"
>
</div>
<form
class=
"well form-inline"
onsubmit=
"return false;"
>
<input
class=
"msg input-xlarge"
type=
"text"
placeholder=
"Type something..."
/>
<button
type=
"button"
onClick=
"sendMessage1()"
class=
"btn"
id=
"send"
>
Send
</button>
<button
type=
"button"
onClick=
"sendDisconnect1()"
class=
"btn"
>
Disconnect
</button>
</form>
</div>
<div
id=
"chat2"
style=
"width: 49%; float: right;"
>
<h4>
chat2
</h4>
<div
class=
"console well"
>
</div>
<form
class=
"well form-inline"
onsubmit=
"return false;"
>
<input
class=
"msg input-xlarge"
type=
"text"
placeholder=
"Type something..."
/>
<button
type=
"button"
onClick=
"sendMessage2()"
class=
"btn"
id=
"send"
>
Send
</button>
<button
type=
"button"
onClick=
"sendDisconnect2()"
class=
"btn"
>
Disconnect
</button>
</form>
</div>
</body>
</html>
zheng-message/zheng-message-client/ssl-event-index.html
0 → 100644
浏览文件 @
a8e1bab2
<!DOCTYPE html>
<html>
<head>
<title>
Demo Chat
</title>
<link
href=
"bootstrap.css"
rel=
"stylesheet"
>
<style>
body
{
padding
:
20px
;
}
#console
{
height
:
400px
;
overflow
:
auto
;
}
.username-msg
{
color
:
orange
;}
.connect-msg
{
color
:
green
;}
.disconnect-msg
{
color
:
red
;}
.send-msg
{
color
:
#888
}
</style>
<script
src=
"js/socket.io/socket.io.js"
></script>
<script
src=
"js/moment.min.js"
></script>
<script
src=
"http://code.jquery.com/jquery-1.10.1.min.js"
></script>
<script>
var
userName
=
'
user
'
+
Math
.
floor
((
Math
.
random
()
*
1000
)
+
1
);
var
socket
=
io
.
connect
(
'
https://localhost:10443
'
);
socket
.
on
(
'
connect
'
,
function
()
{
output
(
'
<span class="connect-msg">Client has connected to the server!</span>
'
);
});
socket
.
on
(
'
chatevent
'
,
function
(
data
)
{
output
(
'
<span class="username-msg">
'
+
data
.
userName
+
'
:</span>
'
+
data
.
message
);
});
socket
.
on
(
'
disconnect
'
,
function
()
{
output
(
'
<span class="disconnect-msg">The client has disconnected!</span>
'
);
});
function
sendDisconnect
()
{
socket
.
disconnect
();
}
function
sendMessage
()
{
var
message
=
$
(
'
#msg
'
).
val
();
$
(
'
#msg
'
).
val
(
''
);
socket
.
emit
(
'
chatevent
'
,
{
userName
:
userName
,
message
:
message
});
}
function
output
(
message
)
{
var
currentTime
=
"
<span class='time'>
"
+
moment
().
format
(
'
HH:mm:ss.SSS
'
)
+
"
</span>
"
;
var
element
=
$
(
"
<div>
"
+
currentTime
+
"
"
+
message
+
"
</div>
"
);
$
(
'
#console
'
).
prepend
(
element
);
}
$
(
document
).
keydown
(
function
(
e
){
if
(
e
.
keyCode
==
13
)
{
$
(
'
#send
'
).
click
();
}
});
</script>
</head>
<body>
<h1>
Netty-socketio Demo Chat
</h1>
<br/>
<div
id=
"console"
class=
"well"
>
</div>
<form
class=
"well form-inline"
onsubmit=
"return false;"
>
<input
id=
"msg"
class=
"input-xlarge"
type=
"text"
placeholder=
"Type something..."
/>
<button
type=
"button"
onClick=
"sendMessage()"
class=
"btn"
id=
"send"
>
Send
</button>
<button
type=
"button"
onClick=
"sendDisconnect()"
class=
"btn"
>
Disconnect
</button>
</form>
</body>
</html>
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/AckChatLauncher.java
0 → 100644
浏览文件 @
a8e1bab2
package
com.zheng.message.server
;
import
com.corundumstudio.socketio.AckCallback
;
import
com.corundumstudio.socketio.AckRequest
;
import
com.corundumstudio.socketio.Configuration
;
import
com.corundumstudio.socketio.SocketIOClient
;
import
com.corundumstudio.socketio.SocketIOServer
;
import
com.corundumstudio.socketio.VoidAckCallback
;
import
com.corundumstudio.socketio.listener.DataListener
;
public
class
AckChatLauncher
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
Configuration
config
=
new
Configuration
();
config
.
setHostname
(
"localhost"
);
config
.
setPort
(
9092
);
final
SocketIOServer
server
=
new
SocketIOServer
(
config
);
server
.
addEventListener
(
"ackevent1"
,
ChatObject
.
class
,
new
DataListener
<
ChatObject
>()
{
@Override
public
void
onData
(
final
SocketIOClient
client
,
ChatObject
data
,
final
AckRequest
ackRequest
)
{
// check is ack requested by client,
// but it's not required check
if
(
ackRequest
.
isAckRequested
())
{
// send ack response with data to client
ackRequest
.
sendAckData
(
"client message was delivered to server!"
,
"yeah!"
);
}
// send message back to client with ack callback WITH data
ChatObject
ackChatObjectData
=
new
ChatObject
(
data
.
getUserName
(),
"message with ack data"
);
client
.
sendEvent
(
"ackevent2"
,
new
AckCallback
<
String
>(
String
.
class
)
{
@Override
public
void
onSuccess
(
String
result
)
{
System
.
out
.
println
(
"ack from client: "
+
client
.
getSessionId
()
+
" data: "
+
result
);
}
},
ackChatObjectData
);
ChatObject
ackChatObjectData1
=
new
ChatObject
(
data
.
getUserName
(),
"message with void ack"
);
client
.
sendEvent
(
"ackevent3"
,
new
VoidAckCallback
()
{
@Override
protected
void
onSuccess
()
{
System
.
out
.
println
(
"void ack from: "
+
client
.
getSessionId
());
}
},
ackChatObjectData1
);
}
});
server
.
start
();
Thread
.
sleep
(
Integer
.
MAX_VALUE
);
server
.
stop
();
}
}
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/BinaryEventLauncher.java
0 → 100644
浏览文件 @
a8e1bab2
package
com.zheng.message.server
;
import
java.io.UnsupportedEncodingException
;
import
com.corundumstudio.socketio.AckRequest
;
import
com.corundumstudio.socketio.Configuration
;
import
com.corundumstudio.socketio.SocketIOClient
;
import
com.corundumstudio.socketio.SocketIOServer
;
import
com.corundumstudio.socketio.Transport
;
import
com.corundumstudio.socketio.listener.DataListener
;
public
class
BinaryEventLauncher
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
,
UnsupportedEncodingException
{
Configuration
config
=
new
Configuration
();
config
.
setHostname
(
"localhost"
);
config
.
setPort
(
9092
);
config
.
setMaxFramePayloadLength
(
1024
*
1024
);
config
.
setMaxHttpContentLength
(
1024
*
1024
);
final
SocketIOServer
server
=
new
SocketIOServer
(
config
);
server
.
addEventListener
(
"msg"
,
byte
[].
class
,
new
DataListener
<
byte
[]>()
{
@Override
public
void
onData
(
SocketIOClient
client
,
byte
[]
data
,
AckRequest
ackRequest
)
{
client
.
sendEvent
(
"msg"
,
data
);
}
});
server
.
start
();
Thread
.
sleep
(
Integer
.
MAX_VALUE
);
server
.
stop
();
}
}
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/ChatLauncher.java
0 → 100644
浏览文件 @
a8e1bab2
package
com.zheng.message.server
;
import
com.corundumstudio.socketio.listener.*
;
import
com.corundumstudio.socketio.*
;
public
class
ChatLauncher
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
Configuration
config
=
new
Configuration
();
config
.
setHostname
(
"localhost"
);
config
.
setPort
(
9092
);
final
SocketIOServer
server
=
new
SocketIOServer
(
config
);
server
.
addEventListener
(
"chatevent"
,
ChatObject
.
class
,
new
DataListener
<
ChatObject
>()
{
@Override
public
void
onData
(
SocketIOClient
client
,
ChatObject
data
,
AckRequest
ackRequest
)
{
// broadcast messages to all clients
server
.
getBroadcastOperations
().
sendEvent
(
"chatevent"
,
data
);
}
});
server
.
start
();
Thread
.
sleep
(
Integer
.
MAX_VALUE
);
server
.
stop
();
}
}
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/ChatObject.java
0 → 100644
浏览文件 @
a8e1bab2
package
com.zheng.message.server
;
public
class
ChatObject
{
private
String
userName
;
private
String
message
;
public
ChatObject
()
{
}
public
ChatObject
(
String
userName
,
String
message
)
{
super
();
this
.
userName
=
userName
;
this
.
message
=
message
;
}
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
}
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/EventChatLauncher.java
0 → 100644
浏览文件 @
a8e1bab2
package
com.zheng.message.server
;
import
com.corundumstudio.socketio.AckRequest
;
import
com.corundumstudio.socketio.Configuration
;
import
com.corundumstudio.socketio.SocketIOClient
;
import
com.corundumstudio.socketio.SocketIOServer
;
import
com.corundumstudio.socketio.listener.DataListener
;
public
class
EventChatLauncher
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
Configuration
config
=
new
Configuration
();
config
.
setHostname
(
"localhost"
);
config
.
setPort
(
9092
);
final
SocketIOServer
server
=
new
SocketIOServer
(
config
);
server
.
addEventListener
(
"chatevent"
,
ChatObject
.
class
,
new
DataListener
<
ChatObject
>()
{
@Override
public
void
onData
(
SocketIOClient
client
,
ChatObject
data
,
AckRequest
ackRequest
)
{
server
.
getBroadcastOperations
().
sendEvent
(
"chatevent"
,
data
);
}
});
server
.
start
();
Thread
.
sleep
(
Integer
.
MAX_VALUE
);
server
.
stop
();
}
}
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/NamespaceChatLauncher.java
0 → 100644
浏览文件 @
a8e1bab2
package
com.zheng.message.server
;
import
com.corundumstudio.socketio.listener.*
;
import
com.corundumstudio.socketio.*
;
public
class
NamespaceChatLauncher
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
Configuration
config
=
new
Configuration
();
config
.
setHostname
(
"localhost"
);
config
.
setPort
(
9092
);
final
SocketIOServer
server
=
new
SocketIOServer
(
config
);
final
SocketIONamespace
chat1namespace
=
server
.
addNamespace
(
"/chat1"
);
chat1namespace
.
addEventListener
(
"message"
,
ChatObject
.
class
,
new
DataListener
<
ChatObject
>()
{
@Override
public
void
onData
(
SocketIOClient
client
,
ChatObject
data
,
AckRequest
ackRequest
)
{
// broadcast messages to all clients
chat1namespace
.
getBroadcastOperations
().
sendEvent
(
"message"
,
data
);
}
});
final
SocketIONamespace
chat2namespace
=
server
.
addNamespace
(
"/chat2"
);
chat2namespace
.
addEventListener
(
"message"
,
ChatObject
.
class
,
new
DataListener
<
ChatObject
>()
{
@Override
public
void
onData
(
SocketIOClient
client
,
ChatObject
data
,
AckRequest
ackRequest
)
{
// broadcast messages to all clients
chat2namespace
.
getBroadcastOperations
().
sendEvent
(
"message"
,
data
);
}
});
server
.
start
();
Thread
.
sleep
(
Integer
.
MAX_VALUE
);
server
.
stop
();
}
}
zheng-message/zheng-message-server/src/main/java/com/zheng/message/server/SslChatLauncher.java
0 → 100644
浏览文件 @
a8e1bab2
package
com.zheng.message.server
;
import
java.io.InputStream
;
import
com.corundumstudio.socketio.AckRequest
;
import
com.corundumstudio.socketio.Configuration
;
import
com.corundumstudio.socketio.SocketIOClient
;
import
com.corundumstudio.socketio.SocketIOServer
;
import
com.corundumstudio.socketio.listener.DataListener
;
public
class
SslChatLauncher
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
Configuration
config
=
new
Configuration
();
config
.
setHostname
(
"localhost"
);
config
.
setPort
(
10443
);
config
.
setKeyStorePassword
(
"test1234"
);
InputStream
stream
=
SslChatLauncher
.
class
.
getResourceAsStream
(
"/keystore.jks"
);
config
.
setKeyStore
(
stream
);
final
SocketIOServer
server
=
new
SocketIOServer
(
config
);
server
.
addEventListener
(
"chatevent"
,
ChatObject
.
class
,
new
DataListener
<
ChatObject
>()
{
@Override
public
void
onData
(
SocketIOClient
client
,
ChatObject
data
,
AckRequest
ackRequest
)
{
server
.
getBroadcastOperations
().
sendEvent
(
"chatevent"
,
data
);
}
});
server
.
start
();
Thread
.
sleep
(
Integer
.
MAX_VALUE
);
server
.
stop
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录