Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-live
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
hqzhdj
cloud-live
Commits
d446c542
Commit
d446c542
authored
Feb 26, 2021
by
胡涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打日志 直播状态
parent
99652083
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
12 deletions
+14
-12
cloud-live-service/src/main/java/com/yizhi/live/application/service/impl/LiveActivityServiceImpl.java
+0
-0
cloud-live-service/src/main/java/com/yizhi/live/application/util/LiveUtil.java
+8
-12
cloud-live-service/src/main/java/com/yizhi/live/application/util/PolyvUtils.java
+6
-0
No files found.
cloud-live-service/src/main/java/com/yizhi/live/application/service/impl/LiveActivityServiceImpl.java
View file @
d446c542
This diff is collapsed.
Click to expand it.
cloud-live-service/src/main/java/com/yizhi/live/application/util/LiveUtil.java
View file @
d446c542
...
@@ -19,11 +19,7 @@ import java.util.*;
...
@@ -19,11 +19,7 @@ import java.util.*;
@Component
@Component
public
class
LiveUtil
{
public
class
LiveUtil
{
private
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
15000
).
setConnectTimeout
(
15000
)
public
static
String
sendHttpPost
(
String
httpUrl
,
Map
<
String
,
String
>
maps
)
{
.
setConnectionRequestTimeout
(
15000
).
build
();
public
String
sendHttpPost
(
String
httpUrl
,
Map
<
String
,
String
>
maps
)
{
HttpPost
httpPost
=
new
HttpPost
(
httpUrl
);
HttpPost
httpPost
=
new
HttpPost
(
httpUrl
);
List
<
NameValuePair
>
nameValuePairs
=
new
ArrayList
<
NameValuePair
>();
List
<
NameValuePair
>
nameValuePairs
=
new
ArrayList
<
NameValuePair
>();
...
@@ -38,14 +34,14 @@ public class LiveUtil {
...
@@ -38,14 +34,14 @@ public class LiveUtil {
return
sendHttpPost
(
httpPost
);
return
sendHttpPost
(
httpPost
);
}
}
private
String
sendHttpPost
(
HttpPost
httpPost
)
{
private
static
String
sendHttpPost
(
HttpPost
httpPost
)
{
CloseableHttpClient
httpClient
=
null
;
CloseableHttpClient
httpClient
=
null
;
CloseableHttpResponse
response
=
null
;
CloseableHttpResponse
response
=
null
;
HttpEntity
entity
=
null
;
HttpEntity
entity
=
null
;
String
responseContent
=
null
;
String
responseContent
=
null
;
try
{
try
{
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
httpPost
.
setConfig
(
requestConfig
);
httpPost
.
setConfig
(
RequestConfig
.
custom
().
setSocketTimeout
(
15000
).
setConnectTimeout
(
15000
).
setConnectionRequestTimeout
(
15000
).
build
()
);
response
=
httpClient
.
execute
(
httpPost
);
response
=
httpClient
.
execute
(
httpPost
);
entity
=
response
.
getEntity
();
entity
=
response
.
getEntity
();
responseContent
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
responseContent
=
EntityUtils
.
toString
(
entity
,
"UTF-8"
);
...
@@ -66,16 +62,16 @@ public class LiveUtil {
...
@@ -66,16 +62,16 @@ public class LiveUtil {
return
responseContent
;
return
responseContent
;
}
}
public
String
generateSign
(
Map
<
String
,
String
>
parray
,
String
secretKey
)
{
public
static
String
generateSign
(
Map
<
String
,
String
>
parray
,
String
secretKey
)
{
Map
<
String
,
String
>
params
=
this
.
paraFilter
(
parray
);
Map
<
String
,
String
>
params
=
paraFilter
(
parray
);
String
concatedStr
=
this
.
concatParams
(
params
);
String
concatedStr
=
concatParams
(
params
);
String
plain
=
secretKey
+
concatedStr
+
secretKey
;
String
plain
=
secretKey
+
concatedStr
+
secretKey
;
String
encrypted
=
MD5Utils
.
getMD5String
(
plain
);
String
encrypted
=
MD5Utils
.
getMD5String
(
plain
);
String
upperCase
=
encrypted
.
toUpperCase
();
String
upperCase
=
encrypted
.
toUpperCase
();
return
upperCase
;
return
upperCase
;
}
}
private
Map
<
String
,
String
>
paraFilter
(
Map
<
String
,
String
>
sArray
)
{
private
static
Map
<
String
,
String
>
paraFilter
(
Map
<
String
,
String
>
sArray
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
if
(
sArray
==
null
||
sArray
.
size
()
<=
0
)
{
if
(
sArray
==
null
||
sArray
.
size
()
<=
0
)
{
return
result
;
return
result
;
...
@@ -91,7 +87,7 @@ public class LiveUtil {
...
@@ -91,7 +87,7 @@ public class LiveUtil {
return
result
;
return
result
;
}
}
private
String
concatParams
(
Map
<
String
,
String
>
params
)
{
private
static
String
concatParams
(
Map
<
String
,
String
>
params
)
{
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
sort
(
keys
);
Collections
.
sort
(
keys
);
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
...
cloud-live-service/src/main/java/com/yizhi/live/application/util/PolyvUtils.java
View file @
d446c542
...
@@ -66,10 +66,12 @@ public class PolyvUtils {
...
@@ -66,10 +66,12 @@ public class PolyvUtils {
public
static
LiveStatusV2
getLiveStatus
(
String
channelId
,
Date
startAt
,
Date
endAt
,
Integer
liveStatus
)
{
public
static
LiveStatusV2
getLiveStatus
(
String
channelId
,
Date
startAt
,
Date
endAt
,
Integer
liveStatus
)
{
// 直播中
// 直播中
if
(
null
!=
liveStatus
&&
liveStatus
.
equals
(
LiveStatusEnum
.
LIVE
.
getCode
()))
{
if
(
null
!=
liveStatus
&&
liveStatus
.
equals
(
LiveStatusEnum
.
LIVE
.
getCode
()))
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----1"
);
return
LiveStatusV2
.
RUNNING
;
return
LiveStatusV2
.
RUNNING
;
}
}
if
(
LiveStatusV2
.
RUNNING
.
getCode
().
equals
(
getThirdLiveStatus
(
channelId
)))
{
if
(
LiveStatusV2
.
RUNNING
.
getCode
().
equals
(
getThirdLiveStatus
(
channelId
)))
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----2"
);
return
LiveStatusV2
.
RUNNING
;
return
LiveStatusV2
.
RUNNING
;
}
}
...
@@ -77,15 +79,19 @@ public class PolyvUtils {
...
@@ -77,15 +79,19 @@ public class PolyvUtils {
// 未开始
// 未开始
if
(
startAt
.
getTime
()
>
currentTime
)
{
if
(
startAt
.
getTime
()
>
currentTime
)
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----3"
);
return
LiveStatusV2
.
UN_START
;
return
LiveStatusV2
.
UN_START
;
}
}
Integer
count
=
getCountByChannel
(
channelId
,
startAt
,
new
Date
(
currentTime
));
Integer
count
=
getCountByChannel
(
channelId
,
startAt
,
new
Date
(
currentTime
));
if
(
count
>
0
)
{
if
(
count
>
0
)
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----4"
);
return
LiveStatusV2
.
REPLAY
;
return
LiveStatusV2
.
REPLAY
;
}
}
if
(
count
<=
0
&&
currentTime
>
endAt
.
getTime
())
{
if
(
count
<=
0
&&
currentTime
>
endAt
.
getTime
())
{
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----5"
);
return
LiveStatusV2
.
END
;
return
LiveStatusV2
.
END
;
}
}
logger
.
info
(
"直播 channel:"
+
channelId
+
"-----6"
);
return
LiveStatusV2
.
UN_START
;
return
LiveStatusV2
.
UN_START
;
}
}
...
...
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