2013-02-05 87 views
1

我正尝试使用XIFF library连接到我的本地XMPP服务器,但我无法这样做。Adob​​e Flex:无法使用XIFF库连接到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服务器。只是想知道我哪里可能会出错。

任何帮助,将不胜感激。

谢谢!

回答

0

看起来像跨域政策问题。尝试:

  1. Locate your policy log file第一

  2. 启动您的SWF

  3. 检查策略文件内容

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

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

为了调试目的adding SWF file location do local-trusted sandbox应该解决所有问题。

相关问题