另一个quickblox问题 - 我在尝试运行我的应用程序时遇到以下错误:
Uncaught TypeError: Cannot read property 'sigBytes' of undefinedquickblox.js:10707 c.HMAC.i.extend.initquickblox.js:10703 i.Hasher.a.extend._createHmacHelperquickblox.js:101 signMessagequickblox.js:35 createSessionquickblox.js:867 QuickBlox.createSessionchat.html:122 (anonymous function)
此错误会阻止用户成功进行身份验证。正在执行的代码如下(不安全,仅仅是概念证据!):
var chatToUser = window.localStorage.getItem("chatToUser");
var username = window.localStorage.getItem("user");
var password = window.localStorage.getItem("pwd");
var params = {login:username,password:password};
console.log("PARAMS: ",params);
$(document).ready(function(){
var chatService = new QBChat(params);
});
// JavaScript SDK initialization
QB.init(QBAPP.appID, QBAPP.authKey, QBAPP.authSecret);
// QuickBlox session creation
QB.createSession(params, function(err, result) {
if (err) {
console.log("ERROR:", err.detail);
} else {
chatUser = {
id: result.user_id,
pass: params.password
};
connectChat();
}
});
function connectChat() {
chatService = new QBChat({
onConnectFailed: onConnectFailed,
onConnectSuccess: onConnectSuccess,
onConnectClosed: onConnectClosed,
onChatMessage: onChatMessage
});
console.log("Chat Service: ", chatService);
console.log("Chat User: ", chatuser);
// connect to QB chat service
chatService.connect(chatUser);
}
/* Callbacks
------------------------------------------------------*/
// Connection is failed
function onConnectFailed() {
alert("We're having some difficulty talking to the server. Please try again later, or get in touch if th eproblem persists.")
}
// Connection is success
function onConnectSuccess() {
//green dot - live - status
alert("Connected.")
}
// Connection is closed
function onConnectClosed() {}
为了成功登录用户进行聊天,我需要做些什么?
如果有帮助,我之前已经根据他们的用户'为他们生成了一个会话。凭证(用户名/密码)。是否可以简单地重用此会话而不是创建一个新会话?
答案 0 :(得分:0)
它只是打我! (添加一些console.logs帮助...)
该应用程序正在寻找QBAPP。(等),这些参数的大小写/下划线格式化在从示例复制后没有排列,因此'undefined'-s回来了,sigbytes的东西摔倒了。所以请注意其他任何有此错误的人 - 在愚蠢的问题唠叨社区之前,请仔细检查您的代码,了解案例和风格!
我希望有人可以从中吸取教训。