标签: strophe

Strophe字符编码问题

我正在开发一个XMPP客户端,并且遇到Strophe(javascript版本)发送/接收消息的问题.

问题是包含"特殊"字符的邮件.例如,如果我发送:

我在这.

将显示外部客户端(即iChat)

我在这里

strophe客户端根本不显示任何内容.

如果我从iChat向strophe客户端发送相同的消息,它会正确显示.

这是我能提出的最基本的示例代码:

<html>
<head>
  <script type='text/javascript' src='strophe.min.js'></script>
  <script type='text/javascript'>
    function onConnect(status) {
        if (status == Strophe.Status.CONNECTED) {
            var message = $msg({to: CONTACT_JID, from: JID, type: 'chat'}).c('body').t("I'm here."); ;
            connection.send(message.tree());
        }
    }
    var connection = new Strophe.Connection('http://bosh.metajack.im:5280/xmpp-httpbind');
    connection.connect(JID, PASS, onConnect);
  </script>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助.

编辑:

出站,似乎Strophe是双重编码.当我输入

它正在发送

<body>I&amp;apos;m</body>
Run Code Online (Sandbox Code Playgroud)

入站,似乎没有正确处理CDATA.任何指导或想法都表示赞赏.

javascript xmpp strophe

7
推荐指数
1
解决办法
1536
查看次数

webclient(websocket.js)的ejabberd连接失败

我已经在Ubunut OS上安装了ejabberd.

  1. 配置ejabberd.yml为:

    port: 5280
        ip: "::"
        module: ejabberd_http
        request_handlers:
          "/ws": ejabberd_http_ws
          "/bosh": mod_bosh
          "/a/b/": mod_foo
          "/api": mod_http_api
        web_admin: true
        http_bind: true
        register: true
        captcha: true
    
    Run Code Online (Sandbox Code Playgroud)
  2. Webclient:https://github.com/processone/xmpp-websocket-client

注意:能够使用jabber客户端和spark连接和聊天.

尝试连接webclient作为获取响应,如下所示:

     client Request: <?xml version="1.0"?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0"
 xmlns="jabber:client" to="localhost" xml:lang="en"
 xmlns:xml="http://www.w3.org/XML/1998/namespace" >

     Server Response: <stream:stream id='14754768778694635521' version='1.0' xml:lang='en'
 xmlns:stream='http://etherx.jabber.org/streams' from='localhost'
 xmlns='jabber:client'>

     <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms></stream:features>

     Client request: <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/>

     Server Response: <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjE2NDY5ODExMTQ0NDkyMDQyMjQxIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNz</challenge>

     Client Request: <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>dXNlcm5hbWU9Im1hbm9qIixyZWFsbT0iIixub25jZT0iMTY0Njk4MTExNDQ0OTIwNDIyNDEiLGNub25jZT0iZDQxZDhjZDk4ZjAwYjIwNGU5ODAwOTk4ZWNmODQyN2UiLG5jPSIwMDAwMDAwMSIscW9wPSJhdXRoIixkaWdlc3QtdXJpPSJ4bXBwL2xvY2FsaG9zdCIscmVzcG9uc2U9ImJhMjhjNTQwYzU5ZTczZGE1NGY1MmU2YjYxYTFhMjlmIixjaGFyc2V0PSJ1dGYtOCI=</response> 

     Server Response: <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD0xMzc3MzJjMzc3M2FhMjIxNzg0Y2RmYTIxY2RkNzZjMQ==</challenge>

     CR: <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>

     SR <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>

     CR: <?xml version="1.0"?><stream:stream …
Run Code Online (Sandbox Code Playgroud)

xmpp ejabberd websocket strophe

7
推荐指数
1
解决办法
158
查看次数

在页面卸载时断开Strophe连接

我使用strophe.js和jQuery编写了一个基于Web的MUC客户端,我正在尝试向该房间发送不可用的状态,并在窗口的jquery unload事件中断开用户连接.如果用户导航或关闭浏览器选项卡,则应将其注销到MUC.

我已经通过页面上的注销按钮测试了我在此事件中运行的代码,所以我很确定该节是正确的.如果浏览器窗口关闭,我认为strophe在发送节时遇到问题.这里有解决方法吗?我也尝试了onbeforeunload事件(我知道它不完全兼容跨浏览器),但这似乎也不起作用.

任何建议都非常感谢!

谢谢,约翰

jquery xmpp strophe

6
推荐指数
1
解决办法
5069
查看次数

为什么Strophe.js没有抛出错误?

示例代码:

var connection = null;

function onConnect(status) {
    im_a_big_error.log('wtf');
    // Why it doesn't throw me an error here ??                                                                                                                                                                                                
}

$().ready(function() {
    connection = new Strophe.Connection('http://localhost:8080/http-bind');
    connection.connect('admin@localhost', 'admin', onConnect);
});
Run Code Online (Sandbox Code Playgroud)

它不会让我在Chrome控制台中出错.

你有想法解决这个问题吗?

javascript strophe

6
推荐指数
1
解决办法
2802
查看次数

Strophe获得无效的SID

我正在使用strophe和jquery构建一个基于Web的客户端,我使用openfire作为服务器.几乎所有它的工作,我可以得到名单,发送和接收消息,但当我试图将我的存在从可用性改为xa或dnd或任何其他服务器停止回答,我开始得到404错误POST和无效的SID消息如下:"NetworkError:404 Invalid SID. - http://myurl.com/ ".

我一直在讨论其他主题,这似乎是我的可用证书的问题,但我没有任何明确的证据证明什么是错的.

提前感谢您的帮助.

sid openfire strophe

6
推荐指数
1
解决办法
1461
查看次数

我们如何在MySQL数据库上存储聊天对话?XMPP Openfire

我正在构建一个Web聊天应用程序.我想在每次按"Enter"按钮后存储双方之间的消息或对话.我正在使用Openfire Server和MySQL数据库.我没有看到存储会话的数据库中的任何表.

那有插件吗?谢谢.我正在使用strophe js库来发送消息.谢谢.

mysql xmpp openfire strophe

6
推荐指数
1
解决办法
9606
查看次数

在Titanium Appcelerator中使用strshe js?

我想使用Strophe.js库在Titanium appcelerator中创建一个聊天应用程序.我也经历过strshe js库及其文档.我相信我们可以使用strophe.js在web中构建基于xmpp的聊天应用程序.

在此先感谢,任何人都可以澄清以下疑惑,

  • 是否可以在我们的Titanium Appcelerator中使用strophe js,如果是,请建议我如何使用它.我试图在钛内部包括strophe js,它显示无法找到模块错误

这是我试过的代码.

Ti.include("includes/strophe.js");
Ti.include("includes/strophe.register.js");
connection.register.connect("localhost:5280", callback, wait, hold);
var callback = function (status) {
    if (status === Strophe.Status.REGISTER) {
        connection.register.fields.username = "newuser";
        connection.register.fields.password = "123456";
        connection.register.submit();
    } else if (status ===  Strophe.Status.REGISTERED) {
        console.log("registered!");
        connection.authenticate();
    } else if (status ===  Strophe.Status.CONNECTED) {
        console.log("logged in!");
    } else {
        // every other status a connection.connect would receive
    }
};
$.index.open();
Run Code Online (Sandbox Code Playgroud)
  • 您能否建议使用可在Titanium Appceleartor中使用的任何其他库来使用XMPP构建聊天应用程序

xmpp ejabberd titanium strophe titanium-mobile

6
推荐指数
1
解决办法
432
查看次数

xmpp消息不发送给选定的朋友

我正在使用平均堆栈应用程序,现在我需要使用XMPP协议制作聊天模块.
我是新与XMPP,我已经使用在节点JS"节点XMPP的服务器"和"节点XMPP的客户端" ,并在角JS"Strophe.js".

我的代码如下:

app.js(服务器端文件)

"use strict";
var express = require("express");
var https = require('https');
var http = require("http");
var fs = require('fs');
var app = express();
var xmppClient = require('node-xmpp-client');
var xmppServer = require('node-xmpp-server');
var AES = require("crypto-js/aes");
var CryptoJS = require("crypto-js");
/**
 * @description all process variables
 */
require("./config/vars")(app);

var hostName = global.hzConfig.qualifiedHostName;

var config = require("./config/config.js")(app, express);



var friendsArr = [];
var server = null
var startServer = function(done) {
    // Sets up the …
Run Code Online (Sandbox Code Playgroud)

xmpp strophe node.js node-xmpp angularjs

6
推荐指数
0
解决办法
246
查看次数

Strophe.addHandler只从响应中读取第一个节点是否正确?

我开始学习strophe库使用,当我使用addHandler解析响应时,它似乎只读取xml响应的第一个节点,所以当我收到像这样的xml时:

<body xmlns='http://jabber.org/protocol/httpbind'>
 <presence xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='avaliable' id='5593:sendIQ'>
  <status/>
 </presence>
 <presence xmlns='jabber:client' from='test@localhost' to='test2@localhost' xml:lang='en'>
  <status />     
 </presence>
 <iq xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='result'>
  <query xmlns='jabber:iq:roster'>
   <item subscription='both' name='test' jid='test@localhost'>
    <group>test group</group>
   </item>
  </query>
 </iq>
</body>
Run Code Online (Sandbox Code Playgroud)

使用处理程序testHandler就是这样的:

connection.addHandler(testHandler,null,"presence");
function testHandler(stanza){
  console.log(stanza);
}
Run Code Online (Sandbox Code Playgroud)

它只记录:

<presence xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='avaliable' id='5593:sendIQ'>
 <status/>
</presence>
Run Code Online (Sandbox Code Playgroud)

我错过了什么?这是一种正确的行为吗?我应该添加更多处理程序来获取其他节吗?谢谢你提前

javascript xmpp strophe

5
推荐指数
1
解决办法
5670
查看次数

使用Strophe.js定制XMPP消息

如何使用Strophe JS库使用XMPP发送自定义消息?

我知道使用$msg( ... );我可以创建一个聊天消息元素并connection.send(m);通过XMPP连接发送它.

我需要一种方法来发送不是为了聊天而是用于"命令"(或其他目的)的消息.

javascript xmpp strophe

5
推荐指数
1
解决办法
2930
查看次数