Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
com.hdp.customerservice
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘文胜
com.hdp.customerservice
Commits
6fb1d4d3
Commit
6fb1d4d3
authored
Jun 16, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
111111
parent
f00d6914
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
303 additions
and
57 deletions
+303
-57
APP.java
src/main/java/com/hdp/customerservice/APP.java
+2
-1
CustomerManager.java
...va/com/hdp/customerservice/websocket/CustomerManager.java
+54
-0
IMManager.java
...ain/java/com/hdp/customerservice/websocket/IMManager.java
+88
-22
IMWebSocketEndpoint.java
...om/hdp/customerservice/websocket/IMWebSocketEndpoint.java
+3
-15
WaiterManager.java
...java/com/hdp/customerservice/websocket/WaiterManager.java
+43
-0
Customer.java
...ava/com/hdp/customerservice/websocket/model/Customer.java
+1
-8
Waiter.java
.../java/com/hdp/customerservice/websocket/model/Waiter.java
+5
-0
Subscriber.java
src/main/java/com/hdp/pi/wechat/Subscriber.java
+1
-1
im.html
src/main/resources/static/im.html
+2
-3
app.js
src/main/resources/static/js/app.js
+104
-7
No files found.
src/main/java/com/hdp/customerservice/APP.java
View file @
6fb1d4d3
...
@@ -38,6 +38,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
...
@@ -38,6 +38,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
import
redis.clients.jedis.JedisPoolConfig
;
import
redis.clients.jedis.JedisPoolConfig
;
import
com.hdp.customerservice.websocket.*
;
import
com.hdp.customerservice.websocket.*
;
import
com.hdp.pi.wechat.Subscriber
;
@PropertySource
(
value
=
"classpath:application.development.properties"
)
@PropertySource
(
value
=
"classpath:application.development.properties"
)
@ComponentScan
@ComponentScan
...
@@ -72,7 +73,7 @@ public class APP extends WebMvcAutoConfiguration
...
@@ -72,7 +73,7 @@ public class APP extends WebMvcAutoConfiguration
}
}
@Bean
@Bean
public
IMWebSocketEndpoint
reverse
WebSocketEndpoint
()
{
public
IMWebSocketEndpoint
im
WebSocketEndpoint
()
{
return
new
IMWebSocketEndpoint
();
return
new
IMWebSocketEndpoint
();
}
}
...
...
src/main/java/com/hdp/customerservice/websocket/CustomerManager.java
0 → 100644
View file @
6fb1d4d3
/**
* @Title: CustomerManager.java
* @Package com.hdp.customerservice.websocket
* @Description: TODO
* @author new12304508_163_com
* @date 2015年6月16日 下午4:49:51
* @version V1.0
*/
package
com
.
hdp
.
customerservice
.
websocket
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.springframework.util.StringUtils
;
import
com.hdp.customerservice.websocket.model.Customer
;
import
com.hdp.pi.wechat.model.BaseEntity
;
public
class
CustomerManager
{
private
static
ConcurrentHashMap
<
String
,
Customer
>
users
=
new
ConcurrentHashMap
<
String
,
Customer
>();
private
CustomerManager
(){}
public
static
Customer
getUserByOpenId
(
String
openId
){
if
(
StringUtils
.
isEmpty
(
openId
)){
return
null
;
}
return
users
.
get
(
openId
);
}
public
static
void
addUser
(
Customer
user
){
if
(
user
==
null
||
StringUtils
.
isEmpty
(
user
.
openId
)){
return
;
}
users
.
put
(
user
.
openId
,
user
);
}
public
static
void
addUserIfNotExist
(
BaseEntity
e
){
String
openId
=
e
.
openId
;
Customer
user
=
users
.
get
(
openId
);
if
(
user
==
null
){
user
=
new
Customer
();
user
.
openId
=
e
.
openId
;
users
.
put
(
openId
,
user
);
}
}
public
static
Customer
[]
getUsers
(){
Customer
[]
us
=
new
Customer
[
users
.
size
()];
return
users
.
values
().
toArray
(
us
);
}
}
src/main/java/com/hdp/customerservice/websocket/IMManager.java
View file @
6fb1d4d3
...
@@ -11,28 +11,27 @@ package com.hdp.customerservice.websocket;
...
@@ -11,28 +11,27 @@ package com.hdp.customerservice.websocket;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
javax.websocket.Session
;
import
javax.websocket.Session
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.
stereotype.Component
;
import
org.springframework.
util.StringUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
Object
;
import
com.hdp.customerservice.websocket.model.Customer
;
import
com.hdp.customerservice.websocket.model.Customer
;
import
com.hdp.customerservice.websocket.model.Waiter
;
import
com.hdp.customerservice.websocket.model.Waiter
;
import
com.hdp.pi.wechat.model.BaseEntity
;
import
com.hdp.pi.wechat.model.BaseEntity
;
@Component
public
class
IMManager
{
public
class
IMManager
{
private
static
Log
log
=
LogFactory
.
getLog
(
IMManager
.
class
);
private
static
Log
log
=
LogFactory
.
getLog
(
IMManager
.
class
);
public
static
ConcurrentHashMap
<
String
,
Customer
>
users
=
new
ConcurrentHashMap
<
String
,
Customer
>();
public
static
ConcurrentHashMap
<
String
,
Waiter
>
public
static
ConcurrentHashMap
<
String
,
Waiter
>
waiters
=
new
ConcurrentHashMap
<
String
,
Waiter
>();
waiters
=
new
ConcurrentHashMap
<
String
,
Waiter
>();
private
static
LinkedBlockingQueue
<
BaseEntity
>
queue
=
new
LinkedBlockingQueue
<
BaseEntity
>();
public
static
void
broadcast
(
String
id
,
String
message
){
public
static
void
broadcast
(
String
id
,
String
message
){
Iterator
<
Waiter
>
ws
=
waiters
.
values
().
iterator
();
Iterator
<
Waiter
>
ws
=
waiters
.
values
().
iterator
();
while
(
ws
.
hasNext
()){
while
(
ws
.
hasNext
()){
...
@@ -47,23 +46,90 @@ public class IMManager {
...
@@ -47,23 +46,90 @@ public class IMManager {
}
}
}
}
public
static
void
pushMessage
(
BaseEntity
message
)
throws
InterruptedException
{
public
static
void
pushMessage
(
BaseEntity
message
){
String
openId
=
message
.
openId
;
CustomerManager
.
addUserIfNotExist
(
message
);
Customer
user
=
users
.
get
(
openId
);
try
{
if
(
user
==
null
){
queue
.
put
(
message
);
user
=
new
Customer
();
}
catch
(
InterruptedException
e
)
{
user
.
openId
=
message
.
openId
;
user
.
waiter
=
waiters
.
get
(
"lws"
);
users
.
put
(
openId
,
user
);
}
}
user
.
messages
.
put
(
message
);
}
BaseEntity
m
=
user
.
messages
.
poll
();
if
(
user
.
waiter
!=
null
&&
user
.
waiter
.
session
!=
null
&&
user
.
waiter
.
session
.
isOpen
()){
static
{
//测试用0.0
try
{
new
Thread
(
new
Runnable
()
{
//消息发射器
user
.
waiter
.
session
.
getBasicRemote
().
sendText
(
JSON
.
toJSONString
(
m
));
}
catch
(
IOException
e
)
{
public
void
hand
(){
e
.
printStackTrace
();
BaseEntity
e
=
queue
.
poll
();
if
(
e
==
null
){
return
;
}
Customer
customer
=
CustomerManager
.
getUserByOpenId
(
e
.
openId
);
if
(
customer
==
null
){
pushMessage
(
e
);
return
;
}
Waiter
waiter
=
WaiterManager
.
getWaiterById
(
customer
.
waiterId
);
if
(
waiter
==
null
){
pushMessage
(
e
);
return
;
}
Session
session
=
waiter
.
session
;
if
(
session
==
null
||
!
session
.
isOpen
()){
pushMessage
(
e
);
return
;
}
try
{
session
.
getBasicRemote
().
sendText
(
JSONObject
.
toJSONString
(
e
));
}
catch
(
IOException
e1
)
{
pushMessage
(
e
);
return
;
}
}
}
}
@Override
public
void
run
()
{
while
(
true
){
hand
();
try
{
Thread
.
sleep
(
10
);
}
catch
(
InterruptedException
e
)
{
}
}
}
}).
start
();
new
Thread
(
new
Runnable
()
{
//分配客服
public
void
hand
(){
Customer
[]
cs
=
CustomerManager
.
getUsers
();
Waiter
[]
ws
=
WaiterManager
.
getWaits
();
for
(
Customer
c
:
cs
)
{
if
(!
StringUtils
.
isEmpty
(
c
.
waiterId
)){
continue
;
}
for
(
Waiter
w
:
ws
){
if
(
w
.
customs
.
size
()
==
0
){
c
.
waiterId
=
w
.
id
;
w
.
customs
.
add
(
c
.
openId
);
continue
;
}
}
}
}
@Override
public
void
run
()
{
while
(
true
){
hand
();
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
}
}
}
}).
start
();
}
}
}
}
src/main/java/com/hdp/customerservice/websocket/IMWebSocketEndpoint.java
View file @
6fb1d4d3
...
@@ -23,27 +23,15 @@ public class IMWebSocketEndpoint {
...
@@ -23,27 +23,15 @@ public class IMWebSocketEndpoint {
@OnOpen
@OnOpen
public
void
handleConnect
(
Session
session
)
throws
IOException
{
public
void
handleConnect
(
Session
session
)
throws
IOException
{
Waiter
waiter
=
new
Waiter
();
Waiter
waiter
=
new
Waiter
();
waiter
.
id
=
session
.
getId
();
waiter
.
name
=
"刘文胜"
+
Math
.
random
();
waiter
.
name
=
"刘文胜"
+
Math
.
random
();
waiter
.
session
=
session
;
waiter
.
session
=
session
;
Iterator
<
Customer
>
cs
=
IMManager
.
users
.
values
().
iterator
();
WaiterManager
.
addWaiter
(
waiter
);
String
openId
=
""
;
while
(
cs
.
hasNext
()){
Customer
c
=
cs
.
next
();
if
(
c
.
waiter
==
null
||
!
c
.
waiter
.
session
.
isOpen
()){
openId
=
c
.
openId
;
break
;
}
}
Customer
user
=
IMManager
.
users
.
get
(
openId
);
if
(
user
!=
null
){
user
.
waiter
=
waiter
;
}
IMManager
.
waiters
.
put
(
"lws"
,
waiter
);
}
}
@OnClose
@OnClose
public
void
handleClose
(
Session
session
){
public
void
handleClose
(
Session
session
){
log
.
info
(
"
关闭
"
);
log
.
info
(
"
111111111111111111111111111111111111111
"
);
}
}
@OnMessage
@OnMessage
...
...
src/main/java/com/hdp/customerservice/websocket/WaiterManager.java
0 → 100644
View file @
6fb1d4d3
/**
* @Title: WaiterManager.java
* @Package com.hdp.customerservice.websocket
* @Description: TODO
* @author new12304508_163_com
* @date 2015年6月16日 下午5:15:41
* @version V1.0
*/
package
com
.
hdp
.
customerservice
.
websocket
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.springframework.util.StringUtils
;
import
com.hdp.customerservice.websocket.model.Customer
;
import
com.hdp.customerservice.websocket.model.Waiter
;
public
class
WaiterManager
{
private
static
ConcurrentHashMap
<
String
,
Waiter
>
waiters
=
new
ConcurrentHashMap
<
String
,
Waiter
>();
private
WaiterManager
(){}
public
static
Waiter
getWaiterById
(
String
id
){
if
(
StringUtils
.
isEmpty
(
id
)){
return
null
;
}
return
waiters
.
get
(
id
);
}
public
static
void
addWaiter
(
Waiter
waiter
){
if
(
waiter
==
null
||
StringUtils
.
isEmpty
(
waiter
.
id
)){
return
;
}
waiters
.
put
(
waiter
.
id
,
waiter
);
}
public
static
Waiter
[]
getWaits
(){
Waiter
[]
ws
=
new
Waiter
[
waiters
.
size
()];
return
waiters
.
values
().
toArray
(
ws
);
}
}
src/main/java/com/hdp/customerservice/websocket/model/Customer.java
View file @
6fb1d4d3
...
@@ -17,14 +17,7 @@ public class Customer {
...
@@ -17,14 +17,7 @@ public class Customer {
public
String
openId
;
public
String
openId
;
public
String
nickName
;
public
String
waiterId
;
public
String
headImg
;
public
Waiter
waiter
;
public
Date
lastTime
;
//最后活动时间
public
Date
lastTime
;
//最后活动时间
public
LinkedBlockingQueue
<
BaseEntity
>
messages
=
new
LinkedBlockingQueue
<
BaseEntity
>();
}
}
\ No newline at end of file
src/main/java/com/hdp/customerservice/websocket/model/Waiter.java
View file @
6fb1d4d3
...
@@ -8,6 +8,9 @@
...
@@ -8,6 +8,9 @@
*/
*/
package
com
.
hdp
.
customerservice
.
websocket
.
model
;
package
com
.
hdp
.
customerservice
.
websocket
.
model
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.websocket.Session
;
import
javax.websocket.Session
;
public
class
Waiter
{
public
class
Waiter
{
...
@@ -18,4 +21,6 @@ public class Waiter {
...
@@ -18,4 +21,6 @@ public class Waiter {
public
String
headImg
;
public
String
headImg
;
public
Session
session
;
public
Session
session
;
public
List
<
String
>
customs
=
new
ArrayList
<
String
>();
}
}
src/main/java/com/hdp/
customerservice
/Subscriber.java
→
src/main/java/com/hdp/
pi/wechat
/Subscriber.java
View file @
6fb1d4d3
package
com
.
hdp
.
customerservice
;
package
com
.
hdp
.
pi
.
wechat
;
import
org.dom4j.Document
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentException
;
...
...
src/main/resources/static/im.html
View file @
6fb1d4d3
...
@@ -150,7 +150,7 @@
...
@@ -150,7 +150,7 @@
<div
ng-repeat=
"m in messages"
ng-class=
"{true:'msg_bubble_list bubble_l',false:'msg_bubble_list bubble_r'}[m.type==1]"
style=
"display: block"
>
<div
ng-repeat=
"m in messages"
ng-class=
"{true:'msg_bubble_list bubble_l',false:'msg_bubble_list bubble_r'}[m.type==1]"
style=
"display: block"
>
<div
class=
"bubble_mod clearfix"
>
<div
class=
"bubble_mod clearfix"
>
<div
class=
"bubble_user"
>
<div
class=
"bubble_user"
>
<a
href=
"http://weibo.com/u/3955027752"
target=
"_blank"
class=
"face default_face"
><img
_src=
"#{avatarurl}"
width=
"30"
height=
"30"
src=
"http://tp1.sinaimg.cn/3955027752/30/5728607898/1
"
/></a>
<a
href=
"http://weibo.com/u/3955027752"
target=
"_blank"
class=
"face default_face"
><img
width=
"30"
height=
"30"
src=
"{{m.headimgurl}}
"
/></a>
</div>
</div>
<p
class=
"bubble_name W_autocut"
style=
"height: 15px;display:none"
href=
"http://weibo.com/u/3955027752"
target=
"_blank"
>
海东青童鞋
</p>
<p
class=
"bubble_name W_autocut"
style=
"height: 15px;display:none"
href=
"http://weibo.com/u/3955027752"
target=
"_blank"
>
海东青童鞋
</p>
<p
class=
"bubble_prompt"
style=
"display: none;"
><span
class=
"W_icon icon_rederrorS"
></span>
发送失败,请输入验证码
</p>
<p
class=
"bubble_prompt"
style=
"display: none;"
><span
class=
"W_icon icon_rederrorS"
></span>
发送失败,请输入验证码
</p>
...
@@ -164,8 +164,7 @@
...
@@ -164,8 +164,7 @@
</div>
</div>
<div
class=
"bubble_main clearfix"
>
<div
class=
"bubble_main clearfix"
>
<div
class=
"cont"
>
<div
class=
"cont"
>
<p
class=
"page"
>
<p
class=
"page"
ng-bind-html=
"m.message"
>
{{m.message}}
</p>
</p>
</div>
</div>
</div>
</div>
...
...
src/main/resources/static/js/app.js
View file @
6fb1d4d3
...
@@ -82,26 +82,123 @@ websocketApp.controller('UserListCtrl',
...
@@ -82,26 +82,123 @@ websocketApp.controller('UserListCtrl',
}]);
}]);
websocketApp
.
controller
(
'MessagesCtrl'
,
websocketApp
.
controller
(
'MessagesCtrl'
,
[
'$scope'
,
'$rootScope'
,
'$location'
,
'$resource'
,
'$stateParams'
,
'WebSocketService'
,
[
'$scope'
,
'$rootScope'
,
'$location'
,
'$resource'
,
'$stateParams'
,
'
$sce'
,
'
WebSocketService'
,
function
(
$scope
,
$rootScope
,
$location
,
$resource
,
$stateParams
,
WebSocketService
)
{
function
(
$scope
,
$rootScope
,
$location
,
$resource
,
$stateParams
,
$sce
,
WebSocketService
)
{
$scope
.
message
=
""
;
$scope
.
message
=
""
;
var
messages
=
$scope
.
messages
=
[];
var
messages
=
$scope
.
messages
=
[];
var
tplMessage
=
{
touser
:
'ogoz1t65VSnKQQvYrD9-SLBL2KIk'
,
msgtype
:
'text'
,
text
:
{
content
:
''
}
};
var
news
=
{
touser
:
'ogoz1t65VSnKQQvYrD9-SLBL2KIk'
,
msgtype
:
'news'
,
news
:{
articles
:
[
{
title
:
'Happy Day'
,
description
:
'Is Really A Happy Day'
,
url
:
'https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign=a5c6f9f036fa828bd176cea39b227506/faf2b2119313b07ed3782dfd09d7912396dd8c79.jpg'
,
picurl
:
'https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/super/whfpf%3D425%2C260%2C50/sign=a5c6f9f036fa828bd176cea39b227506/faf2b2119313b07ed3782dfd09d7912396dd8c79.jpg'
}]
}
};
$scope
.
$on
(
'text'
,
function
(
event
,
data
)
{
$scope
.
$on
(
'text'
,
function
(
event
,
data
)
{
$scope
.
$apply
(
function
(){
$scope
.
$apply
(
function
(){
console
.
log
(
data
);
var
m
=
{
type
:
1
,
message
:
''
};
messages
.
push
({
type
:
1
,
message
:
data
.
content
});
m
.
message
=
$sce
.
trustAsHtml
(
data
.
content
);
$resource
(
'http://sandbox.wxpai.cn/open/user/info?appId=wx3e055e220ddde820&openId='
+
data
.
openId
)
.
get
({},
function
(
res
){
m
.
headimgurl
=
res
.
data
.
headimgurl
;
m
.
openid
=
res
.
data
.
openid
;
},
function
(
res
){
});
messages
.
push
(
m
);
});
});
});
});
$scope
.
$on
(
'image'
,
function
(
event
,
data
)
{
$scope
.
$apply
(
function
(){
if
(
data
.
mediaId
){
var
m
=
{
type
:
1
,
message
:
''
};
var
picUrl
=
'http://sandbox.wxpai.cn/open/media/get?appId=wx3e055e220ddde820&mediaId='
+
data
.
mediaId
;
m
.
message
=
$sce
.
trustAsHtml
(
'<img src=
\
"'
+
picUrl
+
'" style="height:50px;width:50px;"/>'
);
messages
.
push
(
m
);
}
});
});
function
pv_q
(
u
,
w
,
h
){
var
pv
=
''
;
pv
+=
'<object data="'
+
u
+
'" width="'
+
w
+
'" height="'
+
h
+
'" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
;
pv
+=
'<param name="src" value="'
+
u
+
'">'
;
pv
+=
'<param name="controller" value="true">'
;
pv
+=
'<param name="type" value="video/quicktime">'
;
pv
+=
'<param name="autoplay" value="true">'
;
pv
+=
'<param name="target" value="myself">'
;
pv
+=
'<param name="bgcolor" value="black">'
;
pv
+=
'<param name="pluginspage" value="http://www.apple.com/quicktime/download/index.html">'
;
pv
+=
'<embed src="'
+
u
+
'" width="'
+
w
+
'" height="'
+
h
+
'" controller="true" align="middle" bgcolor="black" target="myself" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/index.html"></embed>'
;
pv
+=
'</object>'
;
return
pv
;
}
$scope
.
$on
(
'voice'
,
function
(
event
,
data
)
{
$scope
.
$apply
(
function
(){
if
(
data
.
mediaId
){
var
m
=
{
type
:
1
,
message
:
''
};
var
voiceUrl
=
'http://sandbox.wxpai.cn/open/media/get?appId=wx3e055e220ddde820&mediaId='
+
data
.
mediaId
;
/*m.message = $sce.trustAsHtml('<audio controls="controls" src=\"'+voiceUrl+'" style="height:50px;width:50px;"/>');*/
m
.
message
=
$sce
.
trustAsHtml
(
pv_q
(
voiceUrl
,
'150px'
,
'50px'
));
messages
.
push
(
m
);
}
});
});
$scope
.
$on
(
'video'
,
function
(
event
,
data
)
{
$scope
.
$apply
(
function
(){
if
(
data
.
mediaId
){
var
m
=
{
type
:
1
,
message
:
''
};
var
videoUrl
=
'http://sandbox.wxpai.cn/open/media/get?appId=wx3e055e220ddde820&mediaId='
+
data
.
mediaId
;
m
.
message
=
$sce
.
trustAsHtml
(
'<video controls="controls" src=
\
"'
+
voiceUrl
+
'" width="100px;" heiht="100px"/>'
);
messages
.
push
(
m
);
}
});
});
$scope
.
$on
(
'shortvideo'
,
function
(
event
,
data
)
{
$scope
.
$apply
(
function
(){
if
(
data
.
mediaId
){
var
m
=
{
type
:
1
,
message
:
''
};
var
shortvideoUrl
=
'http://sandbox.wxpai.cn/open/media/get?appId=wx3e055e220ddde820&mediaId='
+
data
.
mediaId
;
m
.
message
=
$sce
.
trustAsHtml
(
'<video controls="controls" src=
\
"'
+
shortvideoUrl
+
'" width="100px;" heiht="100px"/>'
);
messages
.
push
(
m
);
}
});
});
$scope
.
send
=
function
(){
$scope
.
send
=
function
(){
if
(
$scope
.
message
){
if
(
$scope
.
message
){
messages
.
push
({
type
:
2
,
message
:
$scope
.
message
});
var
m
=
{
type
:
2
,
message
:
''
};
WebSocketService
.
sendMessage
(
$scope
.
message
).
then
(
function
(
res
)
{
m
.
message
=
$sce
.
trustAsHtml
(
$scope
.
message
);
messages
.
push
(
m
);
/*WebSocketService.sendMessage($scope.message).then(function(res) {
messages.push({type:1,message:res.message});
messages.push({type:1,message:res.message});
}, function(res) {
}, function(res) {
console.log(res);
console.log(res);
});
});*/
tplMessage
.
text
.
content
=
$scope
.
message
;
$resource
(
'http://sandbox.wxpai.cn/open/custom_send?appId=wx3e055e220ddde820'
)
.
save
(
news
,
function
(
res
){
console
.
log
(
res
);
},
function
(
res
){
console
.
log
(
res
);
});
$scope
.
message
=
""
;
$scope
.
message
=
""
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment