Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
409444ee
authored
Dec 10, 2019
by
patpat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加每10分钟自动发送心跳包
parent
5a0b75db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
app/src/main/java/com/bgycc/smartcanteen/action/ActionEnum.java
+1
-0
app/src/main/java/com/bgycc/smartcanteen/server/websocket/MainWebSocket.java
+15
-0
No files found.
app/src/main/java/com/bgycc/smartcanteen/action/ActionEnum.java
View file @
409444ee
...
@@ -4,6 +4,7 @@ public enum ActionEnum {
...
@@ -4,6 +4,7 @@ public enum ActionEnum {
// 检查设备
// 检查设备
CHECK_DEVICE
,
CHECK_DEVICE
,
AUTO_CHECK_DEVICE
,
// 支付
// 支付
PAY_
,
PAY_
,
...
...
app/src/main/java/com/bgycc/smartcanteen/server/websocket/MainWebSocket.java
View file @
409444ee
...
@@ -48,6 +48,7 @@ public class MainWebSocket extends WebSocketClient {
...
@@ -48,6 +48,7 @@ public class MainWebSocket extends WebSocketClient {
private
static
MainWebSocket
sInstance
;
private
static
MainWebSocket
sInstance
;
private
static
String
sDeviceSN
;
private
static
String
sDeviceSN
;
private
static
int
sReconnectTimes
=
0
;
private
static
int
sReconnectTimes
=
0
;
private
static
int
sAutoCheckCount
=
0
;
public
static
void
initialize
()
{
public
static
void
initialize
()
{
if
(
sInstance
==
null
)
{
if
(
sInstance
==
null
)
{
...
@@ -72,6 +73,20 @@ public class MainWebSocket extends WebSocketClient {
...
@@ -72,6 +73,20 @@ public class MainWebSocket extends WebSocketClient {
NetworkManager
.
INSTANCE
.
switchNetwork
();
NetworkManager
.
INSTANCE
.
switchNetwork
();
EventBus
.
getDefault
().
post
(
new
ConnectStateEvent
(
ConnectStateEvent
.
CHANGE_NETWORK
));
EventBus
.
getDefault
().
post
(
new
ConnectStateEvent
(
ConnectStateEvent
.
CHANGE_NETWORK
));
}
}
sAutoCheckCount
=
0
;
}
else
{
// 每10分钟发一次心跳包给后端
sAutoCheckCount
-=
2
;
if
(
sAutoCheckCount
<
0
)
{
sAutoCheckCount
=
10
*
60
;
try
{
JSONObject
data
=
new
JSONObject
();
data
.
put
(
FieldEnum
.
equipmentId
.
name
(),
sDeviceSN
);
action
(
ActionEnum
.
AUTO_CHECK_DEVICE
.
name
(),
data
,
null
);
}
catch
(
Exception
e
)
{
}
}
}
}
}
}
},
2000
,
-
1
,
2000
);
},
2000
,
-
1
,
2000
);
...
...
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