Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-10-23 14:36:55 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d2ca51ac50afd9cbb618072015d9ac33de737267
d2ca51ac
1 parent
71451878
notify kafka when client close
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
38 行增加
和
4 行删除
trunk/src/app/srs_app_kafka.cpp
trunk/src/app/srs_app_kafka.hpp
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_kafka.cpp
查看文件 @
d2ca51a
...
...
@@ -383,6 +383,13 @@ void SrsKafkaProducer::stop()
int
SrsKafkaProducer
::
on_client
(
int
key
,
SrsListenerType
type
,
string
ip
)
{
int
ret
=
ERROR_SUCCESS
;
bool
enabled
=
_srs_config
->
get_kafka_enabled
();
if
(
!
enabled
)
{
return
ret
;
}
SrsJsonObject
*
obj
=
SrsJsonAny
::
object
();
obj
->
set
(
"msg"
,
SrsJsonAny
::
str
(
"accept"
));
...
...
@@ -392,6 +399,22 @@ int SrsKafkaProducer::on_client(int key, SrsListenerType type, string ip)
return
worker
->
execute
(
new
SrsKafkaMessage
(
this
,
key
,
obj
));
}
int
SrsKafkaProducer
::
on_close
(
int
key
)
{
int
ret
=
ERROR_SUCCESS
;
bool
enabled
=
_srs_config
->
get_kafka_enabled
();
if
(
!
enabled
)
{
return
ret
;
}
SrsJsonObject
*
obj
=
SrsJsonAny
::
object
();
obj
->
set
(
"msg"
,
SrsJsonAny
::
str
(
"close"
));
return
worker
->
execute
(
new
SrsKafkaMessage
(
this
,
key
,
obj
));
}
int
SrsKafkaProducer
::
send
(
int
key
,
SrsJsonObject
*
obj
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_kafka.hpp
查看文件 @
d2ca51a
...
...
@@ -137,11 +137,16 @@ public:
public
:
/**
* when got any client connect to SRS, notify kafka.
* @param key the partition map key,
a id or hash
.
* @param key the partition map key,
the client id or hash(ip)
.
* @param type the type of client.
* @param ip the peer ip of client.
*/
virtual
int
on_client
(
int
key
,
SrsListenerType
type
,
std
::
string
ip
)
=
0
;
/**
* when client close or disconnect for error.
* @param key the partition map key, the client id or hash(ip).
*/
virtual
int
on_close
(
int
key
)
=
0
;
};
/**
...
...
@@ -168,11 +173,10 @@ public:
virtual
int
initialize
();
virtual
int
start
();
virtual
void
stop
();
// interface ISrsKafkaCluster
public:
/**
* when got any client connect to SRS, notify kafka.
*/
virtual
int
on_client
(
int
key
,
SrsListenerType
type
,
std
::
string
ip
);
virtual
int
on_close
(
int
key
);
// for worker to call task to send object.
public:
/**
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
d2ca51a
...
...
@@ -1556,6 +1556,13 @@ int SrsRtmpConn::on_disconnect()
http_hooks_on_close
();
#ifdef SRS_AUTO_KAFKA
if
((
ret
=
kafka
->
on_close
(
srs_id
()))
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify kafka failed. ret=%d"
,
ret
);
return
ret
;
}
#endif
// TODO: implements it.
return
ret
;
...
...
请
注册
或
登录
后发表评论