Red5的一般客户端连接各个事件的触发顺序
假设用户登录的地址是
rtmp://localhost/MyChatRoom/lobby/roomA
以下是事件按先后顺序排列
程序开始
appStart:MyChatRoom
Start:
(在RED5启动的时候会自动去启动APP,从而触发以上事件)
登录
roomStart:/lobby
Start:/lobby
roomStart:/lobby/roomA
Start:/lobby/roomA
appConnect:0
connect
appJoin:0:
roomConnect:0
connect:/lobby
roomJoin:0:/lobby
roomConnect:0
connect:/lobby/roomA
roomJoin:0:/lobby/roomA
第二个用户登录
appConnect:1
connect
appJoin:1:
roomConnect:1
connect:/lobby
roomJoin:1:/lobby
roomConnect:1
connect:/lobby/roomA
roomJoin:1:/lobby/roomA
第二个用户离开
roomDisconnect:1
disconnect:/lobby/roomA
roomLeave:1:/lobby/roomA
roomDisconnect:1
disconnect:/lobby
roomLeave:1:/lobby
appDisconnect:1
disconnect:
appLeave:1:
离开
roomDisconnect:0
disconnect:/lobby/roomA
roomLeave:0:/lobby/roomA
roomStop:/lobby/roomA
stop:/lobby/roomA
roomDisconnect:0
disconnect:/lobby
roomLeave:0:/lobby
roomStop:/lobby
stop:/lobby
appDisconnect
disconnect:
appLeave:0:
总结:
rtmp://localhost/MyChatRoom/lobby/roomA
GlobalScope(default) –> WebScope(MyChatRoom) –> Scope(lobby)
–> Scope(roomA)
进入时:
先从第一个Scope,lobby开始,
1,执行房间启动ApplicationMBean.roomStart(IScope lobby)
2,执行启动IScopeHandler.start(IScope lobby)
再开始到第二个Scope,roomA开始
3,执行房间启动ApplicationMBean.roomStart(IScope roomA)
4,执行启动IScopeHandler.start(IScope roomA)
5.然后开始执行ApplicationMBean.appConnect(IConnection conn,Object[] params)
6,执行IScopeHandler.connect(IConnection conn, IScope app, Object[] params)
7,然后执行ApplicationMBean.appJoin(IClient client, IScope app)
从第一个Scope,lobby开始,
8,然后执行ApplicationMBean.roomConnect(IConnection conn, Object[] params)
9,执行IScopeHandler.connect(IConnection conn, IScope lobby, Object[] params)
10,执行ApplicationMBean.roomJoin(IClient client, IScope lobby)
第二个Scope,roomA开始,
11,然后执行ApplicationMBean.roomConnect(IConnection conn, Object[] params)
12,执行IScopeHandler.connect(IConnection conn, IScope roomA, Object[] params)
13,执行ApplicationMBean.roomJoin(IClient client, IScope roomA)
当第二个用户进入同一房间时,房间不用重新建立,故从步骤5开始执行
当第二个用户离开时
从最外层的Scope(roomA)开始
1,执行ApplicationMBean.roomDisconnect(IConnection conn)
2,执行IScopeHandler.disconnect(IConnection conn, IScope roomA)
3,执行ApplicationMBean.roomLeave(IClient client, IScope roomA)
再到Scope(lobby)
4,执行ApplicationMBean.roomDisconnect(IConnection conn)
5,执行IScopeHandler.disconnect(IConnection conn, IScope lobby)
6,执行ApplicationMBean.roomLeave(IClient client, IScope lobby)
再是WebScope(MyChatRoom)
7,执行ApplicationMBean.appDisconnect(IConnection conn)
8,执行IScopeHandler.disconnect(IConnection conn, IScope app)
9,执行ApplicationMBean.appLeave(IClient client, IScope app)
当第一个,也是最后一个用户也离开的时候.情况相似.
只不过在roomLeave之后,会接着关闭这个房间
先调用ApplicationMBean.roomStop(IScope room)
再调用IScopeHandler.stop(IScope roomScope)
app不会因为所有客户都不在而自动关闭.
转贴请注明出处:lunastudio.cn
本文出自 传播、沟通、分享,转载时请注明出处及相应链接。
本文永久链接: https://www.nickdd.cn/?p=1090