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

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

问题描述

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



更新我没有使用服务器组件,但是我在Linux上托管了这个东西。正如 Artem Tikhomirov 所提到的那样(

问题的作者)在他的自己的答案,我的答案是没有帮助的(我保留下面作为wiki,为档案)。



真正的答案是由 Ric Tokyo <有关 Linux上的错误,并记录在 $ /
$ / $ /

我的答案是选择的唯一原因是因为Artem没有选择任何其他的答案(或他自己的答案)在7天的限制之前,给我(第一个也是最高的答案)一半的奖励点数(超过150)自动,如




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




$ b


在开发应用程序时,请注意使用组件会引入显式 onConnectAccept onConnectReject 事件。

您需要包含处理这些事件的代码。

当您使用组件时,您必须修改 application.onConnect在你的服务器端代码中包含 application.onConnectAccept application.onConnectReject 事件处理程序。
onConnect 处理程序的最后一行(按执行顺序)应该是 application.acceptConnection() application.rejectConnection()。如果您的应用程序在显式 acceptConnection() rejectConnection()之后需要额外的代码, 方法(例如指示用户已被授予或拒绝应用程序权限的消息),则应将该代码放在 application.onConnectAccept application.onConnectReject 语句。

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







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

<$ p $ NetStatusEvent non pris en charge:level = error,code = NetStream.Play.Failed
at MethodInfo-1()
错误#2044:NetStatusEvent non pris在MethodInfo-1()



上填充:level = error,code = NetStream.Record.NoAccess
<如果客户端从服务器读取数据流,它必须使服务器端的服务器异常,并强制意外退出。



NetConnection成功
NetStreams(in和out)监听NET_STATUS / li>


一个好的代码会这样:

  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);






$由于新版本的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天全站免登陆