应用启动时触发的方法:
1:start
2:appStart(只是在应用启动时触发一次)
第一个客户端链接服务器时
假如调用的url为:rtmp://localhost/HelloWorld/1/2/3
1:start
2:roomStart
1,2循环调用3次,scope.getName分别为1,2,3
当第二个客户端链接时,上面两个将不会被调用
3:connect
scope.getName为HelloWorld(注:此方法会被调用多次)
4:appConnect
只调用一次,scope.getName为3
5:join
scope.getName为HelloWorld(注:此方法会被调用多次)
6:appJoin
只调用一次,scope.getName为HelloWorld
7:connect
8:roomConnect
9:join
10:roomJoin
上面4个会循环1-3循环调用3次,其中只有8的scope.getName始终为最末端的3
根据以上触发事件的顺序,建议在appConnect方法中进行用户权限判断
(
start会在应用启动的时候调用一次,故不建议采用,
roomStart不能得到客户端传递参数
connect在第一次调用的时候,其scope.getName始终为根scope
)
客户端关闭网页时触发时(最后一个离开):
1:disconnect:scopeName:6
2:roomDisconnect:scopeName:6
3:leave:scopeName:6
4:roomLeave:scopeName:6
5:stop:scopeName:6
6:roomStop:scopeName:6
7:disconnect:scopeName:HelloWorld
8:appDisconnect:scopeName:6
9:leave:scopeName:HelloWorld
10:appLeave:scopeName:HelloWorld
客户端关闭网页时触发时(还有其他的用户在线):
1:disconnect:scopeName:6
2:roomDisconnect:scopeName:6
3:leave:scopeName:6
4:roomLeave:scopeName:6
5:disconnect:scopeName:HelloWorld
6:appDisconnect:scopeName:6
7:leave:scopeName:HelloWorld
8:appLeave:scopeName:HelloWorld
客户端离开不止一层的房间(最后一个离开)
1:disconnect:scopeName:6
2:roomDisconnect:scopeName:6
3:leave:scopeName:6
4:roomLeave:scopeName:6
5:stop:scopeName:6
6:roomStop:scopeName:6
7:disconnect:scopeName:1
8:roomDisconnect:scopeName:6
9:leave:scopeName:1
10:roomLeave:scopeName:1
11:stop:scopeName:1
12:roomStop:scopeName:1
13:disconnect:scopeName:HelloWorld
14:appDisconnect:scopeName:6
15:leave:scopeName:HelloWorld
16:appLeave:scopeName:HelloWorld