Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cmu
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李维杰
cmu
Commits
0da033fc
Commit
0da033fc
authored
Jun 19, 2020
by
李维杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改请求相关逻辑
parent
8a3b42dd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletions
+33
-1
cmd_processer_server.cc
cmu/src/cmd_processer_server.cc
+1
-0
cmd_processer_server.h
cmu/src/cmd_processer_server.h
+5
-0
mqtt_request.cc
thirdparty/mqtt/mqtt_request.cc
+22
-0
mqtt_request.h
thirdparty/mqtt/mqtt_request.h
+5
-1
No files found.
cmu/src/cmd_processer_server.cc
View file @
0da033fc
#include "cmd_processer_server.h"
#include "mqtt_request.h"
namespace
offcn
{
...
...
cmu/src/cmd_processer_server.h
View file @
0da033fc
#pragma once
#include "mqtt_wrapper.h"
#include <map>
namespace
offcn
{
...
...
@@ -26,5 +27,8 @@ namespace offcn
private
:
MqttWrapper
*
mqtt_wrapper_
;
private
:
std
::
map
<
std
::
string
,
std
::
string
>
client_lists_
;
};
}
\ No newline at end of file
thirdparty/mqtt/mqtt_request.cc
View file @
0da033fc
...
...
@@ -74,6 +74,28 @@ namespace offcn
return
Json
::
writeString
(
wBuilder
,
root
);
}
static
bool
GetJsonValue
(
std
::
string
&
response
,
Json
::
Value
&
root
)
{
Json
::
CharReaderBuilder
readerBuilder
;
std
::
unique_ptr
<
Json
::
CharReader
>
const
reader
(
readerBuilder
.
newCharReader
());
const
char
*
start_pos
=
response
.
c_str
();
std
::
string
err
;
if
(
!
reader
->
parse
(
start_pos
,
start_pos
+
response
.
length
(),
&
root
,
&
err
))
{
return
false
;
}
return
true
;
}
bool
MqttRequest
::
ParseRequest
(
std
::
string
&
req
,
std
::
string
&
path
,
ReqValue
&
values
)
{
Json
::
Value
root
;
if
(
!
GetJsonValue
(
req
,
root
))
return
false
;
}
std
::
string
MqttRequest
::
JoinResponse
(
std
::
string
ids
,
std
::
string
result
)
{
Json
::
Value
root
;
...
...
thirdparty/mqtt/mqtt_request.h
View file @
0da033fc
#pragma once
#include <string>
#include <map>
namespace
offcn
{
typedef
std
::
map
<
std
::
string
,
std
::
string
>
ReqValue
;
class
MqttRequest
{
public
:
static
std
::
string
JoinRequest
(
std
::
string
local_id
);
static
std
::
string
UpdateRequest
(
std
::
string
local_id
,
std
::
string
pull_type
);
static
std
::
string
Candidate
(
std
::
string
local_id
,
std
::
string
remote_id
,
std
::
string
type
,
std
::
string
candidate
);
static
bool
ParseRequest
(
std
::
string
&
req
,
std
::
string
&
path
,
ReqValue
&
values
);
static
std
::
string
JoinResponse
(
std
::
string
ids
,
std
::
string
result
);
static
std
::
string
UpdateResponse
(
std
::
string
result
);
};
...
...
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