代码之家  ›  专栏  ›  技术社区  ›  SSpoke

adobe startus文本聊天中断@连接设置

  •  1
  • SSpoke  · 技术社区  · 15 年前

    使用Jquery@

    $("#flashtxtchat").get(0).startTxtChat()
    
    • 参数错误:错误#2126:
    <![CDATA[
        import flash.events.*;
        import flash.external.*;
        import flash.net.*;
        import flash.system.*;
    
        import mx.containers.*;
        import mx.controls.*;
        import mx.core.*;
        import mx.events.*;
        import mx.styles.*;
        import mx.utils.*;
    
        private var netConnection:NetConnection;
        private var sendStream:NetStream;
        private var receiveStream:NetStream;
        private var strangerPeerID:String;
    
        public function init() : void
        {
            var url:* = FlexGlobals.topLevelApplication.url;
            var serverName:* = URLUtil.getServerName(url);
            if (!serverName.match(/(localhost|127.0.0.1)$/))
            {
                return;
            }
            ExternalInterface.addCallback("startTxtChat", this.startChat);
            ExternalInterface.addCallback("gotStrangerPeerID", this.gotStrangerPeerID);
            ExternalInterface.addCallback("sendMsg", this.sendMsg);
            ExternalInterface.addCallback("stopTxtChat", this.stopChat);
            ExternalInterface.call("flashtxtChat_init");
            return;
        }// end function
    
        public function startChat() : void
        {
            if (this.netConnection)
            {
                ExternalInterface.call("flashtxtChat_gotNearID", this.netConnection.nearID);
            }
            else
            {
                this.netConnection = new NetConnection();
                this.netConnection.addEventListener(NetStatusEvent.NET_STATUS, this.netConnectionHandler);
                this.netConnection.connect("rtmfp://stratus.rtmfp.net/removed-removed/");
            }
            return;
        }// end function
    
        public function gotStrangerPeerID(param1:String) : void
        {
            var _loc_3:NetStream = null;
            this.strangerPeerID = param1;
            var _loc_2:int = 0;
            while (_loc_2 < this.sendStream.peerStreams.length)
            {
    
                _loc_3 = this.sendStream.peerStreams[_loc_2];
                if (_loc_3.farID != this.strangerPeerID)
                {
                    _loc_3.close();
                }
                _loc_2++;
            }
            this.receiveStream = new NetStream(this.netConnection, this.strangerPeerID);
            this.receiveStream.play("textchat");
            this.receiveStream.client = this;///temp added by me
            //this.strangerVideo.attachNetStream(this.receiveStream);
            return;
        }// end function
    
        public function sendMsg(msg: String) : void
        {
            sendStream.send("recvMsg", msg);
        }
    
        public function recvMsg(msg: String) : void
        {
            ExternalInterface.call("recvMsg", msg);
        }
    
        public function stopChat() : void
        {
            this.strangerPeerID = null;
            return;
        }// end function
    
        public function netConnectionHandler(event:NetStatusEvent) : void
        {
            var c:Object;
            var event:* = event;
            switch(event.info.code)
            {
                case "NetConnection.Connect.Success":
                {
                    c = new Object();
                    c.onPeerConnect = function (param1:NetStream) : Boolean
                    {
                        if (strangerPeerID == null)
                        {
                            return true;
                        }
                        return param1.farID == strangerPeerID;
                    };// end function
                    this.sendStream = new NetStream(this.netConnection, NetStream.DIRECT_CONNECTIONS);
                    this.sendStream.client = c;
                    this.sendStream.publish("textchat");
                    ExternalInterface.call("flashtxtChat_gotNearID", this.netConnection.nearID);
                    break;
                }
                case "NetConnection.Connect.Failed":
                {
                    this.netConnection = null;
                    ExternalInterface.call("flashCb_errorConnectingToStratus");
                    break;
                }
                case "NetConnection.Connect.Closed":
                {
                    this.netConnection = null;
                    this.sendStream.close();
                    this.sendStream = null;
                    if (this.receiveStream)
                    {
                        this.receiveStream.close();
                        this.receiveStream = null;
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function
    ]]>
    </mx:Script>
    

    有什么问题吗?谢谢,我用了一个类似的视频聊天的实现,工作完美,我只是删除了所有视频相关的功能,只留下在文本聊天现在它不工作?

    1 回复  |  直到 15 年前
        1
  •  0
  •   peter    14 年前

    检查更新后重置的播放器设置是否允许本地p2p