我正在尝试使用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服务器。只是想知道我在哪里做错了。
任何帮助都将不胜感激。
谢谢!
发布于 2013-04-30 15:17:26
看起来像是跨域策略问题。尝试:
另一种做同样事情的方法是打开浏览器网络日志,检查Flash是否像http://localhost/crossdomain.xml一样试图加载文件。
这个问题有两种通用的解决方案:
crossdomain.xml from your server XMPP data所在主机上的XMPP SWF文件
出于调试目的,adding SWF file location do local-trusted sandbox应该解决所有问题。
https://stackoverflow.com/questions/14704348
复制相似问题