Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
2b5acbda
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b5acbda
编写于
5月 28, 2013
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add handling for remaining STOMP server commands
上级
69ef364e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
12 deletion
+34
-12
spring-websocket/src/main/java/org/springframework/web/messaging/stomp/server/RelayStompService.java
...amework/web/messaging/stomp/server/RelayStompService.java
+5
-0
spring-websocket/src/main/java/org/springframework/web/messaging/stomp/server/ServerStompMessageHandler.java
...web/messaging/stomp/server/ServerStompMessageHandler.java
+29
-12
未找到文件。
spring-websocket/src/main/java/org/springframework/web/messaging/stomp/server/RelayStompService.java
浏览文件 @
2b5acbda
...
...
@@ -69,6 +69,11 @@ public class RelayStompService {
this
.
reactor
.
on
(
Fn
.
$
(
StompCommand
.
SUBSCRIBE
),
new
RelayConsumer
());
this
.
reactor
.
on
(
Fn
.
$
(
StompCommand
.
SEND
),
new
RelayConsumer
());
this
.
reactor
.
on
(
Fn
.
$
(
StompCommand
.
DISCONNECT
),
new
RelayConsumer
());
this
.
reactor
.
on
(
Fn
.
$
(
StompCommand
.
ACK
),
new
RelayConsumer
());
this
.
reactor
.
on
(
Fn
.
$
(
StompCommand
.
NACK
),
new
RelayConsumer
());
this
.
reactor
.
on
(
Fn
.
$
(
StompCommand
.
BEGIN
),
new
RelayConsumer
());
this
.
reactor
.
on
(
Fn
.
$
(
StompCommand
.
COMMIT
),
new
RelayConsumer
());
this
.
reactor
.
on
(
Fn
.
$
(
StompCommand
.
ABORT
),
new
RelayConsumer
());
this
.
reactor
.
on
(
Fn
.
$
(
"CONNECTION_CLOSED"
),
new
Consumer
<
Event
<
String
>>()
{
@Override
...
...
spring-websocket/src/main/java/org/springframework/web/messaging/stomp/server/ServerStompMessageHandler.java
浏览文件 @
2b5acbda
...
...
@@ -78,12 +78,10 @@ public class ServerStompMessageHandler implements StompMessageHandler {
disconnect
(
session
,
message
);
}
else
if
(
StompCommand
.
ACK
.
equals
(
command
)
||
StompCommand
.
NACK
.
equals
(
command
))
{
// TODO
logger
.
warn
(
"Ignoring "
+
command
+
". It is not supported yet."
);
this
.
reactor
.
notify
(
command
,
Fn
.
event
(
message
));
}
else
if
(
StompCommand
.
BEGIN
.
equals
(
command
)
||
StompCommand
.
COMMIT
.
equals
(
command
)
||
StompCommand
.
ABORT
.
equals
(
command
))
{
// TODO
logger
.
warn
(
"Ignoring "
+
command
+
". It is not supported yet."
);
this
.
reactor
.
notify
(
command
,
Fn
.
event
(
message
));
}
else
{
sendErrorMessage
(
session
,
"Invalid STOMP command "
+
command
);
...
...
@@ -174,22 +172,22 @@ public class ServerStompMessageHandler implements StompMessageHandler {
this
.
reactor
.
notify
(
StompCommand
.
CONNECT
,
Fn
.
event
(
stompMessage
,
replyToKey
));
}
protected
void
subscribe
(
final
StompSession
session
,
StompMessage
stompM
essage
)
{
protected
void
subscribe
(
final
StompSession
session
,
StompMessage
m
essage
)
{
final
String
subscription
=
stompM
essage
.
getHeaders
().
getId
();
String
replyToKey
=
StompCommand
.
SUBSCRIBE
+
":"
+
session
.
getId
()
+
":"
+
subscription
;
final
String
subscription
Id
=
m
essage
.
getHeaders
().
getId
();
String
replyToKey
=
getSubscriptionReplyKey
(
session
,
subscriptionId
)
;
// TODO: extract and remember "ack" mode
// http://stomp.github.io/stomp-specification-1.2.html#SUBSCRIBE_ack_Header
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Adding subscription
with replyToK
ey="
+
replyToKey
);
logger
.
trace
(
"Adding subscription
, k
ey="
+
replyToKey
);
}
Registration
<?>
registration
=
this
.
reactor
.
on
(
Fn
.
$
(
replyToKey
),
new
Consumer
<
Event
<
StompMessage
>>()
{
@Override
public
void
accept
(
Event
<
StompMessage
>
event
)
{
event
.
getData
().
getHeaders
().
setSubscription
(
subscription
);
event
.
getData
().
getHeaders
().
setSubscription
(
subscription
Id
);
try
{
session
.
sendMessage
(
event
.
getData
());
}
...
...
@@ -201,13 +199,17 @@ public class ServerStompMessageHandler implements StompMessageHandler {
addRegistration
(
session
.
getId
(),
registration
);
this
.
reactor
.
notify
(
StompCommand
.
SUBSCRIBE
,
Fn
.
event
(
stompM
essage
,
replyToKey
));
this
.
reactor
.
notify
(
StompCommand
.
SUBSCRIBE
,
Fn
.
event
(
m
essage
,
replyToKey
));
// TODO: need a way to communicate back if subscription was successfully created or
// not in which case an ERROR should be sent back and close the connection
// http://stomp.github.io/stomp-specification-1.2.html#SUBSCRIBE
}
private
String
getSubscriptionReplyKey
(
StompSession
session
,
String
subscriptionId
)
{
return
StompCommand
.
SUBSCRIBE
+
":"
+
session
.
getId
()
+
":"
+
subscriptionId
;
}
private
void
addRegistration
(
String
sessionId
,
Registration
<?>
registration
)
{
List
<
Registration
<?>>
list
=
this
.
registrationsBySession
.
get
(
sessionId
);
if
(
list
==
null
)
{
...
...
@@ -217,8 +219,23 @@ public class ServerStompMessageHandler implements StompMessageHandler {
list
.
add
(
registration
);
}
protected
void
unsubscribe
(
StompSession
session
,
StompMessage
stompMessage
)
{
this
.
reactor
.
notify
(
StompCommand
.
UNSUBSCRIBE
,
Fn
.
event
(
stompMessage
));
protected
void
unsubscribe
(
StompSession
session
,
StompMessage
message
)
{
cancelRegistration
(
session
,
message
.
getHeaders
().
getId
());
this
.
reactor
.
notify
(
StompCommand
.
UNSUBSCRIBE
,
Fn
.
event
(
message
));
}
private
void
cancelRegistration
(
StompSession
session
,
String
subscriptionId
)
{
String
key
=
getSubscriptionReplyKey
(
session
,
subscriptionId
);
List
<
Registration
<?>>
list
=
this
.
registrationsBySession
.
get
(
session
.
getId
());
for
(
Registration
<?>
registration
:
list
)
{
if
(
registration
.
getSelector
().
matches
(
key
))
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Cancelling subscription, key="
+
key
);
}
list
.
remove
(
registration
);
registration
.
cancel
();
}
}
}
protected
void
send
(
StompSession
session
,
StompMessage
stompMessage
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录