Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
offcntools
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
李维杰
offcntools
Commits
6ede6a7f
Commit
6ede6a7f
authored
Aug 28, 2024
by
李维杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加日志
parent
8ddb3bac
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
126 deletions
+135
-126
live_get_push_pull_address.vcxproj
..._get_push_pull_address/live_get_push_pull_address.vcxproj
+0
-0
http_client.cpp
thirdparty/curl/http_client.cpp
+0
-0
http_request.cpp
thirdparty/curl/http_request.cpp
+127
-125
filereader.cpp
wb_rebuild/filereader.cpp
+0
-0
rebuild_manager.cpp
wb_rebuild/rebuild_manager.cpp
+8
-1
No files found.
live_get_push_pull_address/live_get_push_pull_address.vcxproj
View file @
6ede6a7f
This diff is collapsed.
Click to expand it.
thirdparty/curl/http_client.cpp
View file @
6ede6a7f
This diff is collapsed.
Click to expand it.
thirdparty/curl/http_request.cpp
View file @
6ede6a7f
#include "http_request.h"
#include "http_client.h"
#include "json/json.h"
#include <map>
#include <list>
HttpRequest
*
HttpRequest
::
instance_
=
nullptr
;
HttpRequest
*
HttpRequest
::
GetInstance
()
{
if
(
instance_
==
nullptr
)
{
instance_
=
new
HttpRequest
();
}
return
instance_
;
}
bool
ParseJson
(
std
::
string
message
,
Json
::
Value
&
root
)
{
Json
::
CharReaderBuilder
readerBuilder
;
std
::
unique_ptr
<
Json
::
CharReader
>
const
reader
(
readerBuilder
.
newCharReader
());
const
char
*
start_pos
=
message
.
c_str
();
std
::
string
err
;
if
(
!
reader
->
parse
(
start_pos
,
start_pos
+
message
.
length
(),
&
root
,
&
err
))
{
return
false
;
}
return
true
;
}
bool
HttpRequest
::
Init
()
{
return
HttpRequest
::
GetInstance
()
->
Load
();
}
bool
HttpRequest
::
LogIn
(
std
::
string
userid
,
std
::
string
password
,
std
::
string
&
token
,
std
::
string
&
roomid
)
{
ZgHttpClient
client
;
std
::
string
params
;
params
=
"nickname="
+
userid
+
"&password="
+
password
+
"&uuid="
+
"{eae23299-d280-4be2-92a7-8494e18c799b}"
;
std
::
map
<
std
::
string
,
std
::
string
>
headers
;
headers
[
"zgl-clienttype"
]
=
"OffcnLiveLR"
;
headers
[
"zgl-systemtype"
]
=
"Windows"
;
headers
[
"zgl-systemversion"
]
=
"10"
;
headers
[
"zgl-clientversion"
]
=
"3.1.1"
;
//"https://test-api.live.offcncloud.com/api/v1/users"
std
::
string
req
=
HttpRequest
::
GetInstance
()
->
web_server_url_
+
"/api/v1/users"
;
std
::
string
response
;
if
(
!
client
.
Post
(
req
,
params
,
headers
,
response
))
{
return
false
;
}
Json
::
Value
root
;
if
(
!
ParseJson
(
response
,
root
))
return
false
;
int
code
=
root
[
"code"
].
asInt
();
if
(
code
!=
0
)
return
false
;
if
(
!
root
[
"data"
])
return
false
;
Json
::
Value
data
=
root
[
"data"
];
if
(
!
data
[
"access_token"
]
||
!
data
[
"room_id"
])
return
false
;
token
=
data
[
"access_token"
].
asString
();
roomid
=
data
[
"room_id"
].
asString
();
return
true
;
}
std
::
string
HttpRequest
::
GetWebServerUrl
()
{
return
HttpRequest
::
GetInstance
()
->
web_server_url_
;
}
bool
HttpRequest
::
Load
()
{
FILE
*
file
=
fopen
(
"./config"
,
"r"
);
if
(
file
==
NULL
)
return
false
;
long
fileSize
=
0
;
fseek
(
file
,
0
,
SEEK_END
);
fileSize
=
ftell
(
file
);
if
(
fileSize
<=
0
)
return
false
;
char
*
p
=
new
char
[
fileSize
];
rewind
(
file
);
long
ret
=
fread
(
p
,
1
,
fileSize
,
file
);
if
(
ret
<=
0
)
{
delete
p
;
fclose
(
file
);
return
false
;
}
std
::
string
message
(
p
);
delete
p
;
Json
::
Value
root
;
Json
::
CharReaderBuilder
readerBuilder
;
std
::
unique_ptr
<
Json
::
CharReader
>
const
reader
(
readerBuilder
.
newCharReader
());
const
char
*
start_pos
=
message
.
c_str
();
std
::
string
err
;
if
(
!
reader
->
parse
(
start_pos
,
start_pos
+
message
.
length
(),
&
root
,
&
err
))
{
return
false
;
}
if
(
root
[
"web_server_url"
])
{
web_server_url_
=
root
[
"web_server_url"
].
asString
();
}
else
{
return
false
;
}
return
true
;
}
#include "http_request.h"
#include "http_client.h"
#include "json/json.h"
#include <map>
#include <list>
HttpRequest
*
HttpRequest
::
instance_
=
nullptr
;
HttpRequest
*
HttpRequest
::
GetInstance
()
{
if
(
instance_
==
nullptr
)
{
instance_
=
new
HttpRequest
();
}
return
instance_
;
}
bool
ParseJson
(
std
::
string
message
,
Json
::
Value
&
root
)
{
Json
::
CharReaderBuilder
readerBuilder
;
std
::
unique_ptr
<
Json
::
CharReader
>
const
reader
(
readerBuilder
.
newCharReader
());
const
char
*
start_pos
=
message
.
c_str
();
std
::
string
err
;
if
(
!
reader
->
parse
(
start_pos
,
start_pos
+
message
.
length
(),
&
root
,
&
err
))
{
return
false
;
}
return
true
;
}
bool
HttpRequest
::
Init
()
{
return
HttpRequest
::
GetInstance
()
->
Load
();
}
bool
HttpRequest
::
LogIn
(
std
::
string
userid
,
std
::
string
password
,
std
::
string
&
token
,
std
::
string
&
roomid
)
{
ZgHttpClient
client
;
std
::
string
params
;
params
=
"nickname="
+
userid
+
"&password="
+
password
+
"&uuid="
+
"{eae23299-d280-4be2-92a7-8494e18c799b}"
;
std
::
map
<
std
::
string
,
std
::
string
>
headers
;
headers
[
"zgl-clienttype"
]
=
"OffcnLiveLR"
;
headers
[
"zgl-systemtype"
]
=
"Windows"
;
headers
[
"zgl-systemversion"
]
=
"10"
;
headers
[
"zgl-clientversion"
]
=
"3.1.1"
;
//"https://test-api.live.offcncloud.com/api/v1/users"
HttpRequest
::
GetInstance
()
->
web_server_url_
=
"https://api.live.offcncloud.com"
;
std
::
string
req
=
HttpRequest
::
GetInstance
()
->
web_server_url_
+
"/api/v1/users"
;
std
::
string
response
;
if
(
!
client
.
Post
(
req
,
params
,
headers
,
response
))
{
return
false
;
}
Json
::
Value
root
;
if
(
!
ParseJson
(
response
,
root
))
return
false
;
int
code
=
root
[
"code"
].
asInt
();
if
(
code
!=
0
)
return
false
;
if
(
!
root
[
"data"
])
return
false
;
Json
::
Value
data
=
root
[
"data"
];
if
(
!
data
[
"access_token"
]
||
!
data
[
"room_id"
])
return
false
;
token
=
data
[
"access_token"
].
asString
();
roomid
=
data
[
"room_id"
].
asString
();
return
true
;
}
std
::
string
HttpRequest
::
GetWebServerUrl
()
{
return
HttpRequest
::
GetInstance
()
->
web_server_url_
;
}
bool
HttpRequest
::
Load
()
{
FILE
*
file
=
fopen
(
"./config"
,
"r"
);
if
(
file
==
NULL
)
return
false
;
long
fileSize
=
0
;
fseek
(
file
,
0
,
SEEK_END
);
fileSize
=
ftell
(
file
);
if
(
fileSize
<=
0
)
return
false
;
char
*
p
=
new
char
[
fileSize
];
rewind
(
file
);
long
ret
=
fread
(
p
,
1
,
fileSize
,
file
);
if
(
ret
<=
0
)
{
delete
p
;
fclose
(
file
);
return
false
;
}
std
::
string
message
(
p
);
delete
p
;
Json
::
Value
root
;
Json
::
CharReaderBuilder
readerBuilder
;
std
::
unique_ptr
<
Json
::
CharReader
>
const
reader
(
readerBuilder
.
newCharReader
());
const
char
*
start_pos
=
message
.
c_str
();
std
::
string
err
;
if
(
!
reader
->
parse
(
start_pos
,
start_pos
+
message
.
length
(),
&
root
,
&
err
))
{
return
false
;
}
if
(
root
[
"web_server_url"
])
{
web_server_url_
=
root
[
"web_server_url"
].
asString
();
}
else
{
return
false
;
}
return
true
;
}
bool
HttpRequest
::
GetPullUrl
(
std
::
string
token
,
std
::
map
<
std
::
string
,
std
::
string
>
&
urls
)
{
ZgHttpClient
client
;
...
...
wb_rebuild/filereader.cpp
View file @
6ede6a7f
This diff is collapsed.
Click to expand it.
wb_rebuild/rebuild_manager.cpp
View file @
6ede6a7f
...
...
@@ -138,7 +138,14 @@ void RebuildManager::CallBackWhiteBoardData(AVPacket &pkt)
std
::
string
req
((
char
*
)
info
.
m_pData
+
6
,
info
.
m_nDataSize
-
6
);
int
index
=
*
(
int
*
)(
info
.
m_pData
+
6
+
8
);
printf
(
"whitebaord's data index = %d
\n
"
,
index
);
//canvas id
char
*
p
=
(
char
*
)
info
.
m_pData
+
32
;
char
tmp
[
32
]
=
{
0
};
memcpy
(
tmp
,
p
,
24
);
printf
(
"whitebaord's data index = %d, canvasid = %s
\n
"
,
index
,
tmp
);
if
(
m_pMqtt
)
{
...
...
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