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
f7f9e113
authored
Jul 15, 2019
by
patpat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改错别词
parent
a0a2109e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
app/src/main/java/com/bgycc/smartcanteen/server/websocket/MainWebSocket.java
+17
-19
No files found.
app/src/main/java/com/bgycc/smartcanteen/server/websocket/MainWebSocket.java
View file @
f7f9e113
...
...
@@ -2,10 +2,8 @@ package com.bgycc.smartcanteen.server.websocket;
import
android.util.Log
;
import
android.util.SparseArray
;
import
com.bgycc.smartcanteen.App
;
import
com.bgycc.smartcanteen.AppConfig
;
import
com.bgycc.smartcanteen.action.ActionEnum
;
import
com.bgycc.smartcanteen.action.Action
;
import
com.bgycc.smartcanteen.action.PayOfflineAction
;
import
com.bgycc.smartcanteen.server.websocket.event.ConnectStateEvent
;
import
com.bgycc.smartcanteen.server.websocket.event.RecvMessageEvent
;
...
...
@@ -151,7 +149,7 @@ public class MainWebSocket extends WebSocketClient {
}
private
int
mSessionId
=
0
;
private
final
SparseArray
<
Re
squest
>
mRes
questList
=
new
SparseArray
<>();
private
final
SparseArray
<
Re
quest
>
mRe
questList
=
new
SparseArray
<>();
private
final
HashMap
<
String
,
ArrayList
<
Response
>>
mSubscribeList
=
new
HashMap
<>();
private
MainWebSocket
(
URI
serverUri
)
{
...
...
@@ -163,18 +161,18 @@ public class MainWebSocket extends WebSocketClient {
if
(
mSessionId
>=
Integer
.
MAX_VALUE
)
mSessionId
=
0
;
mSessionId
++;
Re
squest
resquest
=
new
Res
quest
();
re
s
quest
.
action
=
action
;
re
s
quest
.
time
=
System
.
currentTimeMillis
();
re
s
quest
.
response
=
callback
;
re
s
quest
.
params
=
new
JSONObject
();
re
s
quest
.
params
.
put
(
FieldEnum
.
equipmentId
.
name
(),
sDeviceSN
);
re
s
quest
.
params
.
put
(
FieldEnum
.
serialNumber
.
name
(),
mSessionId
);
re
s
quest
.
params
.
put
(
FieldEnum
.
action
.
name
(),
action
);
re
s
quest
.
params
.
put
(
FieldEnum
.
data
.
name
(),
data
);
mRe
squestList
.
put
(
mSessionId
,
res
quest
);
String
msg
=
re
s
quest
.
params
.
toString
();
Re
quest
request
=
new
Re
quest
();
request
.
action
=
action
;
request
.
time
=
System
.
currentTimeMillis
();
request
.
response
=
callback
;
request
.
params
=
new
JSONObject
();
request
.
params
.
put
(
FieldEnum
.
equipmentId
.
name
(),
sDeviceSN
);
request
.
params
.
put
(
FieldEnum
.
serialNumber
.
name
(),
mSessionId
);
request
.
params
.
put
(
FieldEnum
.
action
.
name
(),
action
);
request
.
params
.
put
(
FieldEnum
.
data
.
name
(),
data
);
mRe
questList
.
put
(
mSessionId
,
re
quest
);
String
msg
=
request
.
params
.
toString
();
Log
.
i
(
TAG
,
String
.
format
(
"send: %s"
,
msg
));
EventBus
.
getDefault
().
post
(
new
SendMessageEvent
(
msg
));
super
.
send
(
msg
);
...
...
@@ -207,9 +205,9 @@ public class MainWebSocket extends WebSocketClient {
if
(
res
!=
null
)
res
.
parse
(
code
,
json
);
}
}
else
{
Re
squest
resquest
=
mRes
questList
.
get
(
sessionId
);
if
(
re
squest
!=
null
&&
res
quest
.
response
!=
null
)
{
re
s
quest
.
response
.
parse
(
code
,
json
);
Re
quest
request
=
mRe
questList
.
get
(
sessionId
);
if
(
re
quest
!=
null
&&
re
quest
.
response
!=
null
)
{
request
.
response
.
parse
(
code
,
json
);
}
}
}
catch
(
JSONException
e
)
{
...
...
@@ -229,7 +227,7 @@ public class MainWebSocket extends WebSocketClient {
ex
.
printStackTrace
();
}
public
static
class
Re
s
quest
{
public
static
class
Request
{
String
action
;
long
time
=
0
;
JSONObject
params
;
...
...
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