0

Adobe Cirrus を使用して、フラッシュ プレーヤー コミュニケーターでボイス チャットを作成しています。ローカル ネットワーク経由で 2 つのフラッシュ プレーヤーを接続する際の問題を処理できません。コンパイル済みの SWF ファイル (192.168.1.2:8080/evm_server/bin) を含む tomcat サーバーがあります。この SWF ファイルをローカル コンピューター (192.168.1.2) で開くと、すべて正常に動作します。ネットワーク内の他のコンピューターにログオンしているクライアントにログインして呼び出すことができますが、他のコンピューターにログインして 192.168.1.2 に呼び出しても何も起こりません (アラートは表示されませんが、表示されるはずです)。これは通信コンポーネントのコードです:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx"
           xmlns:components="pl.rafalo235.evm_client.components.*"
           show="initGroup(event)"
           creationComplete="initApp(event)">

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    <mx:HTTPService id="friendsService"
            method="POST"
            url="{EVMServerConnection.SERVER_ADDRESS}/friends"
            result="friendsService_resultHandler(event)"
            fault="friendsService_faultHandler(event)">
        <mx:request>
            <login>{userAccount.login}</login>
            <password>{password}</password>
        </mx:request>
    </mx:HTTPService>

    <mx:HTTPService id="setPeerIdService"
            method="POST"
            url="{EVMServerConnection.SERVER_ADDRESS}/peerId"
            result="peerIdService_resultHandler(event)"
            fault="peerIdService_faultHandler(event)">
        <mx:request>
            <login>{userAccount.login}</login>
            <password>{password}</password>
            <peerId>{myPeerId}</peerId>
            <a>1</a>
        </mx:request>
    </mx:HTTPService>

    <mx:HTTPService id="clearPeerIdService"
            method="POST"
            url="{EVMServerConnection.SERVER_ADDRESS}/peerId"
            result="peerIdService_resultHandler(event)"
            fault="peerIdService_faultHandler(event)">
        <mx:request>
            <login>{userAccount.login}</login>
            <password>{password}</password>
            <a>0</a>
        </mx:request>
    </mx:HTTPService>
</fx:Declarations>

<fx:Script>
    <![CDATA[
    import flash.events.Event;
    import flash.media.Microphone;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import mx.collections.ArrayCollection;
    import mx.collections.ArrayList;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    import pl.rafalo235.evm_client.data.Account;
    import mx.events.FlexEvent;
    import pl.rafalo235.evm_client.data.Friend;
    import pl.rafalo235.evm_client.events.CallButtonClickEvent;
    import flash.events.NetStatusEvent;
    import mx.controls.Alert;
    import pl.rafalo235.evm_client.net.CirrusServerConnection;
    import pl.rafalo235.evm_client.net.EVMServerConnection;
    import pl.rafalo235.evm_client.events.CirrusServerConnectionEvent;

    [Bindable]
    public var applicationRoot:Main;

    [Bindable]
    public var userAccount:Account;

    [Bindable]
    public var friendsList:ArrayCollection = new ArrayCollection();

    [Bindable]
    private var password:String;


    public function initApp(event:FlexEvent):void {
        friendsListUI.addEventListener(CallButtonClickEvent.CALL_BUTTON_CLICK, onCallButtonClick);
    }

    public function initGroup(event:FlexEvent):void {
        initNetConnection();
        friendsService.send();
    }

    public function destructGroup():void {
        clearPeerIdService.send();
        userAccount = null;
        friendsList.removeAll();
        password = null;
    }

    public function setPassword(password:String):void {
        this.password = password;
    }

    public function friendsService_resultHandler(event:ResultEvent):void {
        if (event.result.friends != null) {
            if (event.result.friends.friend is ArrayCollection) {
                var eventData:ArrayCollection = ArrayCollection(event.result.friends.friend);
                var tmpFriend:Friend = null;

                for each (var eventDataItem:Object in eventData) {
                    tmpFriend = new Friend(eventDataItem);
                    friendsList.addItem(tmpFriend);
                    tmpFriend = null;
                }
            } else {
                friendsList.addItem(new Friend(event.result.friends.friend));
            }
        }
    }

    public function friendsService_faultHandler(event:FaultEvent):void {

    }

    public function switchAuthenticationView(event:MouseEvent):void {
        destructGroup();
        applicationRoot.currentState = "default";
    }

    public function onCallButtonClick(event:Event):void {
        var e:CallButtonClickEvent = CallButtonClickEvent(event);
        connectToPeer(e.friend.peerId);
    }

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~private

    [Bindable]
    private var cirrusServerConnection:CirrusServerConnection;

    private const SERVER_ADDRESS:String = "rtmfp://p2p.rtmfp.net/";
    private const DEVELOPER_KEY:String = "f3161a7e23cab7eeae9ea32d-fe63c3b19868";

    private var netConnection:NetConnection;

    [Bindable]
    private var myPeerId:String;
    private var farPeerID:String;

    private var sendStream:NetStream;
    private var recvStream:NetStream;

    private var mic:Microphone;

    private function initNetConnection():void {
        //cirrusServerConnection = new CirrusServerConnection();
        //cirrusServerConnection.addEventListener(CirrusServerConnectionEvent.CONNECTED, openSendStream);
        //cirrusServerConnection.connect();
        netConnection = new NetConnection();
        netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
        netConnection.connect(SERVER_ADDRESS + DEVELOPER_KEY);

        if (Microphone.isSupported) {
            mic = Microphone.getMicrophone();
            mic.rate = 11;
            mic.setUseEchoSuppression(true);
            mic.gain = 50;
            mic.setSilenceLevel(20);
        }
    }

    private function netStatusHandler(event:NetStatusEvent):void {
        trace("CirrusConnection: " + event.info.code);
        Alert.show("CirrusConnection: " + event.info.code);
        switch(event.info.code) {
            case "NetConnection.Connect.Success":
                myPeerId = netConnection.nearID;
                openSendStream();
                break;
            case "NetStream.Play.Start":
                break;
        }
    }

    private function sendStreamStatusHandler(event:NetStatusEvent):void {
        trace("SendStream: " + event.info.code);
        Alert.show("SendStream: " + event.info.code);
        switch(event.info.code) {
            case "NetStream.Publish.Start":
                setPeerIdService.send();
                break;
            case "NetStream.Play.Start":
                if (Microphone.isSupported) {
                    sendStream.attachAudio(mic);
                } else {
                    Alert.show("Microphone not supported");
                }
                break;
        }
    }

    private function recvStreamStatusHandler(event:NetStatusEvent):void {
        trace("RecvStream: " + event.info.code);
        Alert.show("RecvStream: " + event.info.code);
        switch(event.info.code) {
            case "NetConnection.Connect.Success":
                break;
            case "NetStream.Play.Start":
                recvStream.receiveAudio(true);
                break;
        }
    }

    private function openSendStream():void {
        var sendStreamClient:Object = new Object();
        sendStreamClient.onPeerConnect = function(callerns:NetStream):Boolean {
            trace("peerConnected");
            if (!Boolean(farPeerID)) {
                connectToPeer(callerns.farID);
            }
            return true;
        }

        sendStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);
        sendStream.addEventListener(NetStatusEvent.NET_STATUS, sendStreamStatusHandler);
        sendStream.client = sendStreamClient;
        sendStream.publish("media");
    }

    public function connectToPeer(id:String):void {
        farPeerID = id;
        recvStream = new NetStream(netConnection,farPeerID);
        recvStream.addEventListener(NetStatusEvent.NET_STATUS, recvStreamStatusHandler);
        recvStream.client = this;
        recvStream.play("media");
    }

    public function peerIdService_resultHandler(event:ResultEvent):void {

    }

    public function peerIdService_faultHandler(event:FaultEvent):void {

    }

    ]]>
</fx:Script>

<s:DataGroup id="friendsListUI" 
            dataProvider="{friendsList}"
                itemRenderer="pl.rafalo235.evm_client.components.FriendItemRenderer"
            x="25" y="25"
            width="200" height="550">

    <s:layout>
        <s:VerticalLayout />
    </s:layout>

</s:DataGroup>

<components:LinkButton x="700" y="25"
        label="Logout" 
        skinClass="pl.rafalo235.evm_client.skins.LinkButtonSkin"
        click="switchAuthenticationView(event)" />

</s:Group>

Java サーバー (192.168.1.2:8080/evm_server) 経由でデータベースに他の peerId を発行して取得します。おそらく重要なのは、192.168.1.2 だけがマイクを接続していることです。私は迅速な助けに感謝します。よろしくお願いします。

4

1 に答える 1

0

問題はファイアウォールの構成にありました。オフにすると、問題がなくなりました。

于 2013-01-19T14:06:19.870 に答える