Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
浙江兰德纵横网络技术股份有限公司
o2oa
提交
43f3ab27
o2oa
项目概览
浙江兰德纵横网络技术股份有限公司
/
o2oa
通知
339
Star
10
Fork
6
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
43f3ab27
编写于
5月 15, 2020
作者:
F
fancy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
接收ws消息
上级
ea43d901
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
167 addition
and
33 deletion
+167
-33
o2server/x_message_assemble_communicate/src/main/java/com/x/message/assemble/communicate/jaxrs/im/ActionMsgCreate.java
...essage/assemble/communicate/jaxrs/im/ActionMsgCreate.java
+1
-1
o2web/source/o2_core/o2/xDesktop/WebSocket.js
o2web/source/o2_core/o2/xDesktop/WebSocket.js
+31
-1
o2web/source/x_component_IMV2/$Main/default/icon.png
o2web/source/x_component_IMV2/$Main/default/icon.png
+0
-0
o2web/source/x_component_IMV2/$Main/default/im.html
o2web/source/x_component_IMV2/$Main/default/im.html
+5
-3
o2web/source/x_component_IMV2/$Main/default/style.css
o2web/source/x_component_IMV2/$Main/default/style.css
+7
-5
o2web/source/x_component_IMV2/Main.js
o2web/source/x_component_IMV2/Main.js
+123
-23
未找到文件。
o2server/x_message_assemble_communicate/src/main/java/com/x/message/assemble/communicate/jaxrs/im/ActionMsgCreate.java
浏览文件 @
43f3ab27
...
...
@@ -63,7 +63,7 @@ public class ActionMsgCreate extends BaseAction {
logger
.
error
(
e
);
}
logger
.
info
(
"发送im消息, person: "
+
persons
.
get
(
i
));
MessageConnector
.
send
(
MessageConnector
.
TYPE_IM_CREATE
,
"来自 "
+
name
+
"
的IM
消息"
,
persons
.
get
(
i
),
msg
);
MessageConnector
.
send
(
MessageConnector
.
TYPE_IM_CREATE
,
"来自 "
+
name
+
"
的
消息"
,
persons
.
get
(
i
),
msg
);
}
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
...
...
o2web/source/o2_core/o2/xDesktop/WebSocket.js
浏览文件 @
43f3ab27
...
...
@@ -160,6 +160,9 @@ MWF.xDesktop.WebSocket = new Class({
break
;
case
"
custom_create
"
:
this
.
receiveCustomMessage
(
data
);
case
"
im_create
"
:
console
.
log
(
"
im 消息来了!!!
"
);
this
.
receiveIMMessage
(
data
);
break
;
default
:
}
...
...
@@ -292,7 +295,7 @@ MWF.xDesktop.WebSocket = new Class({
}.
bind
(
this
));
},
receiveCustomMessage
:
function
(
data
){
var
content
=
"
<font style='color: #333; font-weight: bold'>
"
+
MWF
.
LP
.
desktop
.
messsage
.
customMessage
+
"
</font>
"
+
data
.
body
;
var
content
=
"
<font style='color: #333; font-weight: bold'>
"
+
MWF
.
LP
.
desktop
.
messsage
.
customMessage
+
"
:
</font>
"
+
data
.
body
;
var
msg
=
{
"
subject
"
:
MWF
.
LP
.
desktop
.
messsage
.
customMessageTitle
,
"
content
"
:
content
...
...
@@ -300,6 +303,33 @@ MWF.xDesktop.WebSocket = new Class({
var
messageItem
=
layout
.
desktop
.
message
.
addMessage
(
msg
);
var
tooltipItem
=
layout
.
desktop
.
message
.
addTooltip
(
msg
);
},
receiveIMMessage
:
function
(
data
){
var
imBody
=
data
.
body
;
var
jsonBody
=
imBody
.
body
;
var
conversationId
=
imBody
.
conversationId
;
//todo 目前只有一种text类型
var
body
=
JSON
.
parse
(
jsonBody
);
var
content
=
"
<font style='color: #333; font-weight: bold'>
"
+
data
.
title
+
"
</font>
"
+
body
.
body
;
var
msg
=
{
"
subject
"
:
MWF
.
LP
.
desktop
.
messsage
.
customMessageTitle
,
"
content
"
:
content
};
var
messageItem
=
layout
.
desktop
.
message
.
addMessage
(
msg
);
var
options
=
{
"
conversationId
"
:
conversationId
};
messageItem
.
contentNode
.
addEvent
(
"
click
"
,
function
(
e
){
layout
.
desktop
.
message
.
addUnread
(
-
1
);
layout
.
desktop
.
message
.
hide
();
layout
.
desktop
.
openApplication
(
e
,
"
IMV2
"
,
options
);
}.
bind
(
this
));
var
tooltipItem
=
layout
.
desktop
.
message
.
addTooltip
(
msg
);
tooltipItem
.
contentNode
.
addEvent
(
"
click
"
,
function
(
e
){
layout
.
desktop
.
message
.
hide
();
layout
.
desktop
.
openApplication
(
e
,
"
IMV2
"
,
options
);
}.
bind
(
this
));
},
...
...
o2web/source/x_component_IMV2/$Main/default/icon.png
查看替换文件 @
ea43d901
浏览文件 @
43f3ab27
4.2 KB
|
W:
|
H:
8.7 KB
|
W:
|
H:
2-up
Swipe
Onion skin
o2web/source/x_component_IMV2/$Main/default/im.html
浏览文件 @
43f3ab27
...
...
@@ -2,13 +2,15 @@
<div
class=
"o2_im_chat_list"
>
<!--top-->
<div
class=
"o2_im_chat_list_top"
>
<div
class=
"add"
data-o2-element=
"o2ImConvCreateNode"
data-o2-events=
"click:tapCreateSingleConv"
></div>
<div
class=
"search_out"
>
<div
class=
"add"
data-o2-element=
"o2ImConvCreateNode"
data-o2-events=
"click:tapCreateSingleConv"
>
创建单聊
</div>
<!-- <div class="search_out">
<div title="搜索" class="search_icon"></div>
<div class="search_input_out">
<input type="text" x-webkit-speech="x-webkit-speech" placeholder="请输入搜索" class="search_input">
</div>
</div>
</div>
-->
</div>
<!-- chat list -->
...
...
o2web/source/x_component_IMV2/$Main/default/style.css
浏览文件 @
43f3ab27
...
...
@@ -18,11 +18,13 @@
border-bottom
:
1px
solid
rgb
(
204
,
204
,
204
);
}
.o2_im_chat_list_top
.add
{
background
:
url(/x_component_IMV2/$Main/default/icons/add.png)
center
center
no-repeat
;
width
:
40px
;
height
:
40px
;
cursor
:
pointer
;
float
:
right
;
background
:
url(/x_component_IMV2/$Main/default/icons/add.png)
left
center
no-repeat
;
height
:
40px
;
cursor
:
pointer
;
margin-left
:
14px
;
text-align
:
center
;
line-height
:
40px
;
color
:
#848484
;
}
.o2_im_chat_list_top
.search_out
{
margin-right
:
40px
;
...
...
o2web/source/x_component_IMV2/Main.js
浏览文件 @
43f3ab27
MWF
.
require
(
"
MWF.widget.UUID
"
,
null
,
false
);
MWF
.
xDesktop
.
requireApp
(
"
Template
"
,
"
MForm
"
,
null
,
false
);
MWF
.
xDesktop
.
requireApp
(
"
Template
"
,
"
MPopupForm
"
,
null
,
false
);
MWF
.
xApplication
.
IMV2
.
options
.
multitask
=
true
;
MWF
.
xApplication
.
IMV2
.
Main
=
new
Class
({
Extends
:
MWF
.
xApplication
.
Common
.
Main
,
Implements
:
[
Options
,
Events
],
...
...
@@ -15,41 +14,70 @@ MWF.xApplication.IMV2.Main = new Class({
"
height
"
:
"
768
"
,
"
isResize
"
:
true
,
"
isMax
"
:
true
,
"
title
"
:
MWF
.
xApplication
.
IMV2
.
LP
.
title
"
title
"
:
MWF
.
xApplication
.
IMV2
.
LP
.
title
,
"
conversationId
"
:
""
},
onQueryLoad
:
function
()
{
this
.
lp
=
MWF
.
xApplication
.
IMV2
.
LP
;
this
.
app
=
this
;
this
.
conversationList
=
[];
this
.
conversationNodeItemList
=
[];
this
.
conversationId
=
""
;
this
.
conversationId
=
this
.
options
.
conversationId
||
""
;
this
.
messageList
=
[];
},
onQueryClose
:
function
(){
console
.
log
(
"
关闭聊天窗口。。。。
"
);
this
.
closeListening
()
},
loadApplication
:
function
(
callback
)
{
var
url
=
this
.
path
+
this
.
options
.
style
+
"
/im.html
"
;
this
.
content
.
loadHtml
(
url
,
{
"
bind
"
:
{
"
lp
"
:
this
.
lp
,
"
data
"
:
{}
},
"
module
"
:
this
},
function
()
{
//设置content
this
.
app
.
content
=
this
.
o2ImMainNode
;
//启动监听
this
.
startListening
();
//获取会话列表
this
.
conversationNodeItemList
=
[];
o2
.
Actions
.
load
(
"
x_message_assemble_communicate
"
).
ImAction
.
myConversationList
(
function
(
json
)
{
if
(
json
.
data
&&
json
.
data
instanceof
Array
)
{
this
.
conversationList
=
json
.
data
;
this
.
loadConversationList
(
json
.
data
);
}
}.
bind
(
this
));
}.
bind
(
this
));
},
startListening
:
function
(){
this
.
messageNumber
=
layout
.
desktop
.
message
.
items
.
length
;
//查询ws消息 如果增加
if
(
this
.
listener
)
{
clearInterval
(
this
.
listener
);
}
this
.
listener
=
setInterval
(
function
(){
var
newNumber
=
layout
.
desktop
.
message
.
items
.
length
;
//判断是否有新的ws消息
if
(
newNumber
>
this
.
messageNumber
)
{
//查询会话数据
this
.
_checkConversationMessage
();
//查询聊天数据
this
.
_checkNewMessage
();
this
.
messageNumber
=
newNumber
;
}
}.
bind
(
this
),
1000
);
},
closeListening
:
function
()
{
if
(
this
.
listener
)
{
clearInterval
(
this
.
listener
);
}
},
//加载会话列表
loadConversationList
:
function
(
list
)
{
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
var
chat
=
list
[
i
];
var
itemNode
=
this
.
_createConvItemNode
(
chat
);
this
.
conversationNodeItemList
.
push
(
itemNode
);
if
(
this
.
conversationId
&&
this
.
conversationId
==
chat
.
id
)
{
this
.
tapConv
(
chat
);
}
}
if
(
list
.
length
>
0
)
{
this
.
tapConv
(
list
[
0
]);
}
console
.
log
(
"
结束
"
);
},
//分页获取会话的消息列表数据
...
...
@@ -57,17 +85,18 @@ MWF.xApplication.IMV2.Main = new Class({
var
data
=
{
"
conversationId
"
:
convId
};
o2
.
Actions
.
load
(
"
x_message_assemble_communicate
"
).
ImAction
.
msgListByPaging
(
page
,
size
,
data
,
function
(
json
)
{
var
list
=
json
.
data
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
this
.
_buildMsgNode
(
list
[
i
]);
this
.
messageList
.
push
(
list
[
i
]);
this
.
_buildMsgNode
(
list
[
i
],
true
);
}
console
.
log
(
"
聊天信息添加结束!
"
);
}.
bind
(
this
),
function
(
error
)
{
console
.
log
(
error
);
}.
bind
(
this
),
false
);
},
//点击
//点击
会话
tapConv
:
function
(
conv
)
{
console
.
log
(
"
clickConversationvvvvvv
"
);
this
.
_setCheckNode
(
conv
);
var
url
=
this
.
path
+
this
.
options
.
style
+
"
/chat.html
"
;
var
data
=
{
"
convName
"
:
conv
.
title
};
...
...
@@ -75,6 +104,7 @@ MWF.xApplication.IMV2.Main = new Class({
this
.
chatNode
.
empty
();
this
.
chatNode
.
loadHtml
(
url
,
{
"
bind
"
:
data
,
"
module
"
:
this
},
function
()
{
//获取聊天信息
this
.
messageList
=
[];
this
.
loadMsgListByConvId
(
1
,
20
,
conv
.
id
);
console
.
log
(
"
开始滚动!!!
"
);
var
scrollFx
=
new
Fx
.
Scroll
(
this
.
chatContentNode
);
...
...
@@ -83,25 +113,21 @@ MWF.xApplication.IMV2.Main = new Class({
},
//点击发送消息
sendMsg
:
function
()
{
console
.
log
(
"
click send Msg btn................
"
);
var
text
=
this
.
chatBottomAreaTextareaNode
.
value
;
console
.
log
(
text
);
if
(
text
)
{
this
.
chatBottomAreaTextareaNode
.
value
=
""
;
this
.
_newAndSendTextMsg
(
text
);
var
scrollFx
=
new
Fx
.
Scroll
(
this
.
chatContentNode
);
scrollFx
.
toBottom
();
}
else
{
console
.
log
(
"
没有消息内容!
"
);
}
},
//点击创建单聊按钮
tapCreateSingleConv
:
function
()
{
console
.
log
(
"
click tapCreateSingleConv................
"
);
var
form
=
new
MWF
.
xApplication
.
IMV2
.
SingleForm
(
this
,
{},
{},
{
app
:
this
.
app
});
form
.
create
()
},
/**
* 创建会话
* @param {*} persons 人员列表
...
...
@@ -115,11 +141,10 @@ MWF.xApplication.IMV2.Main = new Class({
var
_self
=
this
;
o2
.
Actions
.
load
(
"
x_message_assemble_communicate
"
).
ImAction
.
create
(
conv
,
function
(
json
)
{
var
newConv
=
json
.
data
;
console
.
log
(
newConv
);
var
isOld
=
false
;
for
(
var
i
=
0
;
i
<
_self
.
conversationNodeItemList
.
length
;
i
++
)
{
var
c
=
_self
.
conversationNodeItemList
[
i
];
if
(
newConv
.
id
==
c
.
id
)
{
if
(
newConv
.
id
==
c
.
data
.
id
)
{
isOld
=
true
;
_self
.
tapConv
(
c
);
}
...
...
@@ -134,9 +159,11 @@ MWF.xApplication.IMV2.Main = new Class({
console
.
log
(
error
);
}.
bind
(
this
))
},
//创建会话ItemNode
_createConvItemNode
:
function
(
conv
)
{
return
new
MWF
.
xApplication
.
IMV2
.
ConversationItem
(
conv
,
this
);
},
//会话ItemNode 点击背景色
_setCheckNode
:
function
(
conv
)
{
for
(
var
i
=
0
;
i
<
this
.
conversationNodeItemList
.
length
;
i
++
)
{
var
item
=
this
.
conversationNodeItemList
[
i
];
...
...
@@ -170,24 +197,88 @@ MWF.xApplication.IMV2.Main = new Class({
function
(
error
)
{
console
.
log
(
error
);
}.
bind
(
this
));
this
.
messageList
.
push
(
textMessage
);
this
.
_buildSender
(
body
,
distinguishedName
,
false
);
this
.
_refreshConvMessage
(
textMessage
);
},
//刷新会话Item里面的最后消息内容
_refreshConvMessage
:
function
(
msg
)
{
for
(
var
i
=
0
;
i
<
this
.
conversationNodeItemList
.
length
;
i
++
)
{
var
node
=
this
.
conversationNodeItemList
[
i
];
if
(
node
.
data
.
id
==
this
.
conversationId
)
{
node
.
refreshLastMsg
(
textMessage
);
node
.
refreshLastMsg
(
msg
);
}
}
},
//检查会话列表是否有更新
_checkConversationMessage
:
function
()
{
o2
.
Actions
.
load
(
"
x_message_assemble_communicate
"
).
ImAction
.
myConversationList
(
function
(
json
)
{
if
(
json
.
data
&&
json
.
data
instanceof
Array
)
{
var
newConList
=
json
.
data
;
console
.
log
(
newConList
);
for
(
var
j
=
0
;
j
<
newConList
.
length
;
j
++
)
{
var
nCv
=
newConList
[
j
];
var
isNew
=
true
;
for
(
var
i
=
0
;
i
<
this
.
conversationNodeItemList
.
length
;
i
++
)
{
var
cv
=
this
.
conversationNodeItemList
[
i
];
if
(
cv
.
data
.
id
==
nCv
.
id
)
{
isNew
=
false
;
//刷新
cv
.
refreshLastMsg
(
nCv
.
lastMessage
);
}
}
//新会话 创建
if
(
isNew
)
{
var
itemNode
=
this
.
_createConvItemNode
(
nCv
);
this
.
conversationNodeItemList
.
push
(
itemNode
);
}
}
//this.loadConversationList(json.data);
}
}.
bind
(
this
));
},
//检查是否有新消息
_checkNewMessage
:
function
()
{
if
(
this
.
conversationId
&&
this
.
conversationId
!=
""
)
{
//是否有会话窗口
var
data
=
{
"
conversationId
"
:
this
.
conversationId
};
o2
.
Actions
.
load
(
"
x_message_assemble_communicate
"
).
ImAction
.
msgListByPaging
(
1
,
10
,
data
,
function
(
json
)
{
var
list
=
json
.
data
;
if
(
list
&&
list
.
length
>
0
)
{
var
msg
=
list
[
0
];
//检查聊天框是否有变化
if
(
this
.
conversationId
==
msg
.
conversationId
)
{
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
var
isnew
=
true
;
var
m
=
list
[
i
];
for
(
var
j
=
0
;
j
<
this
.
messageList
.
length
;
j
++
)
{
if
(
this
.
messageList
[
j
].
id
==
m
.
id
)
{
isnew
=
false
;
}
}
if
(
isnew
)
{
this
.
messageList
.
push
(
m
);
this
.
_buildMsgNode
(
m
,
false
);
// this._refreshConvMessage(m);
}
}
}
}
}.
bind
(
this
),
function
(
error
)
{
console
.
log
(
error
);
}.
bind
(
this
),
false
);
}
},
//创建消息html节点
_buildMsgNode
:
function
(
msg
)
{
_buildMsgNode
:
function
(
msg
,
isTop
)
{
var
createPerson
=
msg
.
createPerson
;
var
jsonbody
=
msg
.
body
;
var
body
=
JSON
.
parse
(
jsonbody
);
//todo 目前只有一种text类型
var
distinguishedName
=
layout
.
session
.
user
.
distinguishedName
;
if
(
createPerson
!=
distinguishedName
)
{
this
.
_buildReceiver
(
body
,
createPerson
,
true
);
this
.
_buildReceiver
(
body
,
createPerson
,
isTop
);
}
else
{
this
.
_buildSender
(
body
,
createPerson
,
true
);
this
.
_buildSender
(
body
,
createPerson
,
isTop
);
}
},
/**
...
...
@@ -210,6 +301,10 @@ MWF.xApplication.IMV2.Main = new Class({
var
lastFirstNode
=
new
Element
(
"
div
"
,
{
"
class
"
:
"
chat-left_triangle
"
}).
inject
(
lastNode
);
//text
var
lastSecNode
=
new
Element
(
"
span
"
,
{
"
text
"
:
msgBody
.
body
}).
inject
(
lastNode
);
if
(
!
isTop
)
{
var
scrollFx
=
new
Fx
.
Scroll
(
this
.
chatContentNode
);
scrollFx
.
toBottom
();
}
},
/**
* 消息接收体
...
...
@@ -231,6 +326,10 @@ MWF.xApplication.IMV2.Main = new Class({
var
lastFirstNode
=
new
Element
(
"
div
"
,
{
"
class
"
:
"
chat-right_triangle
"
}).
inject
(
lastNode
);
//text
var
lastSecNode
=
new
Element
(
"
span
"
,
{
"
text
"
:
msgBody
.
body
}).
inject
(
lastNode
);
if
(
!
isTop
)
{
var
scrollFx
=
new
Fx
.
Scroll
(
this
.
chatContentNode
);
scrollFx
.
toBottom
();
}
},
//用户头像
_getIcon
:
function
(
id
)
{
...
...
@@ -297,6 +396,7 @@ MWF.xApplication.IMV2.Main = new Class({
day
=
(
day
.
toString
().
length
==
1
)
?
(
"
0
"
+
day
)
:
day
;
return
date
.
getFullYear
()
+
'
-
'
+
month
+
'
-
'
+
day
;
},
//当前时间 yyyy-MM-dd HH:mm:ss
_currentTime
:
function
()
{
var
today
=
new
Date
();
var
year
=
today
.
getFullYear
();
//得到年份
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录