为什么 Flash Media Server 不调用 application.onDisconnect 处理程序? [英] Why Flash Media Server does not call application.onDisconnect handler?

查看:26
本文介绍了为什么 Flash Media Server 不调用 application.onDisconnect 处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Flex/Flashcom 应用程序中遇到了奇怪的问题.如果客户端应用程序意外与服务器断开连接,则后者不会调用 application.onDisconnect 处理函数.我应该朝女巫方向看吗?谢谢.

更新我没有使用服务器组件,但我确实在 Linux 上托管了这个东西.

解决方案

正如 Artem Tikhomirov(问题的作者)在他的自己的答案中,我的答案没有帮助(我将其作为维基保留在下面,以供存档).

Ric Tokyo 给出了关于 Linux 上的错误,记录在 此线程.

我的答案是选择"的唯一原因;是因为 Artem 在 7 天限制之前没有选择任何其他答案(或他自己的答案),给我(第一个也是最多投票的答案)一半的悬赏分(75 超过 150)自动此 SO 博客条目中所述.


第一条线索:

如果客户端是基于组件的应用程序,则需要[正确处理连接事件][9].

<块引用>

在开发应用程序时,请注意使用组件会引入显式的 onConnectAcceptonConnectReject 事件.

<块引用>

您需要包含处理这些事件的代码.
使用组件时,必须修改服务器端代码中的 application.onConnect 语句以包含 application.onConnectAcceptapplication.onConnectReject事件处理程序.
onConnect 处理程序的最后一行(按执行顺序)应该是 application.acceptConnection()application.rejectConnection().

<块引用>

如果您的应用程序需要在显式 acceptConnection()rejectConnection() 方法之后附加代码,例如指示用户已被授予或拒绝权限的消息应用程序,您应该将该代码放在 application.onConnectAcceptapplication.onConnectReject 语句中.

<块引用>

提示:如果您不使用媒体组件,则不能使用 application.onConnectAcceptapplication.onConnectReject.


然后,您可能需要检查 Flash 输出面板中的任何错误消息,例如:

Error #2044: NetStatusEvent non pris en charge: level=error, code=NetStream.Play.Failed在 MethodInfo-1()错误 #2044:NetStatusEvent non pris en charge:级别=错误,代码=NetStream.Record.NoAccess在 MethodInfo-1()

这表示客户端未考虑到服务器异常,从而导致意外退出.

如果客户端从服务器读取流,它必须确保:

  • NetConnection 已成功
  • NetStreams(进出)监听 NET_STATUS

好的代码应该是这样的:

var status:Function = function( e:NetStatusEvent ):void{跟踪(状态:"+ e.info.code);if ( e.info.code == "NetConnection.Connect.Success" ){流输出 = 新的 NetStream( nc ) ;streamOut.addEventListener( NetStatusEvent.NET_STATUS , status ) ;流输入 = 新的 NetStream( nc ) ;streamIn.addEventListener( NetStatusEvent.NET_STATUS , status ) ;streamOut.attachCamera( cam ) ;video.attachNetStream(streamIn);streamOut.publish(私有");streamIn.play(私有");}}

由于新版本的 FlashPlayer 确实会传播此类异常,因此必须对其进行监控,然后在客户端应用程序中捕获它们

I've run into strange problem in my Flex/Flashcom application. If client application unexpectedly disconnects from server latter does not call application.onDisconnect handler function. In witch direction should I look? Thank you.

Update I'm not using server components, but I do host this thing on Linux.

解决方案

As mentioned by Artem Tikhomirov (the author of the question) in his own answer, my answer is not helpful (I keep there below as wiki, for archive).

The real answer has been given by Ric Tokyo regarding a bug on Linux, and is documented in this thread.

The only reason my answer is "chosen" is because Artem did not choose any other answer (or an answer of his own) before the 7 day limits, giving me (the first and most upvoted answer) half of the bounty points (75 over 150) automatically as explained in this SO blog entry.


First lead:

If the client is a component-base application, it needs to [handle connection events properly][9].

When you develop applications, be aware that using components introduces explicit onConnectAccept and onConnectReject events.

You need to include code to handle these events.
When you use components, you must modify the application.onConnect statement in your server-side code to include the application.onConnectAccept and application.onConnectReject event handlers.
The last line (in order of execution) of your onConnect handler should be either application.acceptConnection() or application.rejectConnection().

If your application requires additional code following the explicit acceptConnection() or rejectConnection() methods, such as a message indicating that the user has been granted or denied permission to the application, you should place that code in the application.onConnectAccept or application.onConnectReject statements.

TIP: If you're not using media components, you cannot use application.onConnectAccept and application.onConnectReject.


Then, you may want to check any error message in the Flash output panel, like:

Error #2044: NetStatusEvent non pris en charge : level=error, code=NetStream.Play.Failed
    at MethodInfo-1()
Error #2044: NetStatusEvent non pris en charge : level=error, code=NetStream.Record.NoAccess
    at MethodInfo-1()

That would indicate a server exception non-taken into account by the client, forcing an unexpected exit.

If the client read a stream from the server, it must make sure:

  • the NetConnection has succeeded
  • the NetStreams (in and out) listen to NET_STATUS

A good code would like this:

var status:Function = function( e:NetStatusEvent ):void
{
    trace( "status : " + e.info.code ) ;
    if ( e.info.code == "NetConnection.Connect.Success" )
    {
        streamOut = new NetStream( nc ) ;
        streamOut.addEventListener( NetStatusEvent.NET_STATUS , status ) ;
 
        streamIn  = new NetStream( nc ) ;
        streamIn.addEventListener( NetStatusEvent.NET_STATUS , status ) ;
 
        streamOut.attachCamera( cam ) ;
        video.attachNetStream( streamIn ) ;
 
        streamOut.publish( "private" ) ;
        streamIn.play( "private" ) ;       
    }
}

Since the new versions of FlashPlayer do propagate those kind of exception, they must be monitored and then catch in the client application

这篇关于为什么 Flash Media Server 不调用 application.onDisconnect 处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆