【问题标题】:Adobe Flex: Unable to connect to XMPP server using XIFF libraryAdobe Flex:无法使用 XIFF 库连接到 XMPP 服务器
【发布时间】:2013-01-20 04:36:23
【问题描述】:

我正在尝试使用 XIFF library 连接到我的本地 XMPP 服务器,但是我无法这样做。

我在我的本地主机上安装了eJabberd 并使用 XMPP 客户端 (Pandion) 连接到它,这工作正常...我能够连接到本地 jabber 服务器。

接下来,我尝试使用以下代码连接到 XMPP 服务器:

LoginView.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="Login">
    <s:layout>
        <s:FormLayout/>
    </s:layout>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script source="connection/Connection.as"/>
    <s:Spacer/>
    <s:Label text="Username"/>
    <s:TextInput id="txtUsername" width="200"/>
    <s:Spacer/>
    <s:Label text="Password"/>
    <s:TextInput id="txtPassword" width="200" displayAsPassword="true"/>
    <s:Button id="btnLogin" label="Login" click="login(txtUsername.text, txtPassword.text)" mouseUp="navigator.pushView(HomeView)"/>
</s:View>

Connection.as:

import org.igniterealtime.xiff.conference.Room;
import org.igniterealtime.xiff.core.UnescapedJID;
import org.igniterealtime.xiff.core.XMPPConnection;
import org.igniterealtime.xiff.events.LoginEvent;

private var con:XMPPConnection;
private var room:Room;

private function login (username:String, password:String): void {
    con = new XMPPConnection ();
    con.username = username + "@mydomain";
    con.password = password;
    con.server = "localhost";
    con.port = 5222;
    con.connect (0);
}

但是,我无法使用上面的 ActionScript 代码连接到 XMPP 服务器。只是想知道我可能哪里出错了。

任何帮助将不胜感激。

谢谢!

【问题讨论】:

    标签: actionscript xmpp xiff


    【解决方案1】:

    看起来像一个跨域策略问题。试试:

    1. Locate your policy log file第一

    2. 启动您的 SWF

    3. 检查策略文件内容

    做同样事情的另一种方法是打开浏览器网络日志并检查 Flash 是否正在尝试加载像 http://localhost/crossdomain.xml 这样的文件。

    这个问题有两种通用的解决方案:

    出于调试目的,adding SWF file location do local-trusted sandbox 应该可以解决所有问题。

    【讨论】:

      猜你喜欢
      • 2012-04-14
      • 2013-08-27
      • 1970-01-01
      • 1970-01-01
      • 2015-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多