Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wxBot
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
wxBot
Commits
43db8748
Commit
43db8748
authored
Jul 26, 2017
by
Paul0523
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加缓存消息功能
parent
9f71afa9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
4 deletions
+43
-4
src/main/java/com/yg84/Login.java
src/main/java/com/yg84/Login.java
+34
-3
src/main/java/com/yg84/WeixinApplication.java
src/main/java/com/yg84/WeixinApplication.java
+0
-1
src/main/java/com/yg84/weixin/Message.java
src/main/java/com/yg84/weixin/Message.java
+9
-0
No files found.
src/main/java/com/yg84/Login.java
View file @
43db8748
package
com
.
yg84
;
import
com.yg84.weixin.Contact
;
import
com.yg84.weixin.Message
;
import
com.yg84.weixin.MessageHandler
;
import
com.yg84.weixin.WeChat
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.PostConstruct
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ArrayBlockingQueue
;
/**
* Created by fangzhipeng on 2017/7/16.
...
...
@@ -12,18 +18,43 @@ import java.util.List;
@RestController
public
class
Login
{
public
static
WeChat
weChat
;
ArrayBlockingQueue
<
Message
>
messageQueue
=
new
ArrayBlockingQueue
<
Message
>(
10000
);
@PostConstruct
public
void
initWeChat
()
{
MessageHandler
handler
=
new
MessageHandler
()
{
@Override
public
void
handleMsg
(
List
<
Message
>
messages
)
throws
Exception
{
messageQueue
.
addAll
(
messages
);
System
.
out
.
println
(
"成功加入"
+
messages
.
size
()
+
"条信息"
);
}
};
weChat
=
new
WeChat
(
handler
);
}
@RequestMapping
(
value
=
"/login"
)
public
String
login
()
throws
Exception
{
return
WeixinApplication
.
weChat
.
run
();
return
weChat
.
run
();
}
@RequestMapping
(
value
=
"/sendMsg"
)
public
String
sendMsg
(
String
name
,
String
content
)
throws
Exception
{
return
WeixinApplication
.
weChat
.
sendMsg
(
name
,
content
);
return
weChat
.
sendMsg
(
name
,
content
);
}
@RequestMapping
(
value
=
"/getContact"
)
public
List
<
Contact
>
getContact
()
{
return
WeixinApplication
.
weChat
.
getContacts
();
return
weChat
.
getContacts
();
}
@RequestMapping
(
value
=
"/loadMessage"
)
public
List
<
Message
>
loadMessage
()
{
List
<
Message
>
messages
=
new
ArrayList
<>();
Message
message
;
while
((
message
=
messageQueue
.
poll
())
!=
null
)
{
messages
.
add
(
message
);
}
return
messages
;
}
}
src/main/java/com/yg84/WeixinApplication.java
View file @
43db8748
...
...
@@ -10,7 +10,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public
class
WeixinApplication
{
public
static
WeChat
weChat
=
new
WeChat
(
null
);
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"jsse.enableSNIExtension"
,
"false"
);
...
...
src/main/java/com/yg84/weixin/Message.java
View file @
43db8748
...
...
@@ -5,9 +5,18 @@ package com.yg84.weixin;
*/
public
class
Message
{
private
Integer
msgType
;
private
String
fromUserName
;
private
String
content
;
public
Integer
getMsgType
()
{
return
msgType
;
}
public
void
setMsgType
(
Integer
msgType
)
{
this
.
msgType
=
msgType
;
}
public
String
getFromUserName
()
{
return
fromUserName
;
}
...
...
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