Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FmTakeaway
Overview
Overview
Details
Activity
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
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shangshang.dai
FmTakeaway
Commits
48a42b72
Commit
48a42b72
authored
Sep 26, 2016
by
ss.dai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉soket状态检测
parent
0a48c0b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
fmTakeaway/Control/refundControl.cpp
+16
-10
No files found.
fmTakeaway/Control/refundControl.cpp
View file @
48a42b72
...
...
@@ -31,6 +31,9 @@ void RefundControl::run()
{
QLOG_WARN
()
<<
QString
(
"tcp server listen failed on port[%1]"
).
arg
(
m_port
);
return
;
}
else
{
QLOG_INFO
()
<<
QString
(
"tcp server listened on port[%1]"
).
arg
(
m_port
);
}
m_bContinue
=
true
;
...
...
@@ -41,29 +44,32 @@ void RefundControl::run()
QJsonDocument
jsonDoc
;
while
(
m_bContinue
)
{
QLOG_INFO
()
<<
"waiting new connection...."
;
if
(
!
m_tcpServer
->
waitForNewConnection
(
60000
))
{
continue
;
}
if
(
QAbstractSocket
::
UnknownSocketError
!=
m_tcpServer
->
serverError
())
{
continue
;
}
QLOG_INFO
()
<<
"onNewConnecion....."
;
// if(QAbstractSocket::UnknownSocketError != m_tcpServer->serverError())
// {
// QLOG_INFO() << QString("0socket error %1").arg(m_tcpServer->serverError().errorString());
// continue;
// }
// QLOG_INFO() << QString("1socket error %1").arg(m_tcpServer->serverError().errorString());
QString
error
;
QString
orderId
,
reason
;
int
version
,
reqtype
;
m_tcpSocket
=
m_tcpServer
->
nextPendingConnection
();
if
(
!
m_tcpSocket
->
waitForReadyRead
())
{
QLOG_INFO
()
<<
"read failed"
;
m_tcpSocket
->
close
();
continue
;
}
recvData
=
m_tcpSocket
->
readAll
();
QLOG_INFO
()
<<
QString
(
"recv data.[%1]"
).
arg
(
QString
(
recvData
));
jsonDoc
=
QJsonDocument
::
fromJson
(
recvData
,
&
jsonError
);
jsonDoc
=
QJsonDocument
::
fromJson
(
QString
::
fromUtf8
(
recvData
).
toUtf8
()
,
&
jsonError
);
if
(
jsonError
.
error
==
QJsonParseError
::
NoError
)
{
QJsonObject
jsonObject
=
jsonDoc
.
object
();
...
...
@@ -89,11 +95,11 @@ void RefundControl::run()
.
arg
(
QString
(
QJsonDocument
(
httpRecvJson
).
toJson
(
QJsonDocument
::
Compact
).
replace
(
"
\"
"
,
""
)));
if
(
httpResult
)
{
if
(
100
==
httpRecvJson
[
"status"
].
toInt
())
if
(
100
==
httpRecvJson
[
"status
Code
"
].
toInt
())
{
replyData
=
QString
(
"{
\"
ver
\"
:1,
\"
order_id
\"
:
\"
%1
\"
,
\"
statusCode
\"
:100,
\"
msg
\"
:
\"\"
}"
).
arg
(
orderId
);
m_tcpSocket
->
write
(
replyData
.
toUtf8
());
m_tcpSocket
->
waitForBytesWritten
();
m_tcpSocket
->
waitForBytesWritten
(
5000
);
m_tcpSocket
->
close
();
continue
;
}
else
...
...
@@ -120,7 +126,7 @@ void RefundControl::run()
// 发生错误
replyData
=
QString
(
"{
\"
ver
\"
:1,
\"
order_id
\"
:
\"
%1
\"
,
\"
statusCode
\"
:101,
\"
msg
\"
:
\"
%2
\"
}"
).
arg
(
orderId
).
arg
(
error
);
m_tcpSocket
->
write
(
replyData
.
toUtf8
());
m_tcpSocket
->
waitForBytesWritten
();
m_tcpSocket
->
waitForBytesWritten
(
5000
);
m_tcpSocket
->
close
();
continue
;
}
...
...
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