gpt4 book ai didi

lua - Prosody muc 聊天记录不完整

转载 作者:行者123 更新时间:2023-12-01 14:04:57 26 4
gpt4 key购买 nike

我尝试使用 prosody 进行 session 聊天,对于客户端,我使用 strophe.js。一切都很好,除了一件事,即当用户刚加入房间时向用户显示的聊天记录不完整。例如:一位客户已经向房间发送了这样的消息:

1
2
3
4
5
6
7
8
9
10

但是当新客户加入房间时,他们只会收到这样的消息:

1
3
5
7
9

我尝试在韵律配置中设置 max_history_messages = 10,并从客户端设置 maxstanzas = 10。但还是一样。

这是我的配置文件

admins = { "agent@localhost" }
modules_enabled = {
"message_logging";
"roster";
"saslauth";
"tls";
"dialback";
"disco";

"private";
"vcard";

"version";
"uptime";
"time";
"ping";
"pep";
"register";

"admin_adhoc";
"admin_telnet";

"bosh";

"posix";
};

bosh_ports = { 5280 }
bosh_max_inactivity = 60
consider_bosh_secure = true
cross_domain_bosh = true
http_paths = {
bosh = "/http-bind"; -- Serve BOSH at /http-bind
files = "/"; -- Serve files from the base URL
}

allow_registration = true;

daemonize = true;

pidfile = "/var/run/prosody/prosody.pid";

ssl = {
key = "/etc/prosody/certs/localhost.key";
certificate = "/etc/prosody/certs/localhost.crt";
}

c2s_require_encryption = false

s2s_secure_auth = false

authentication = "internal_plain"

log = {
info = "/var/log/prosody/prosody.log";
error = "/var/log/prosody/prosody.err";
{ levels = { "error" }; to = "syslog"; };
}

VirtualHost "localhost"
enabled = true -- Remove this line to enable this host
ssl = {
key = "/etc/prosody/certs/localhost.key";
certificate = "/etc/prosody/certs/localhost.crt";
}

Component "conference.localhost" "muc"
restrict_room_creation = true
max_history_messages = 10

Include "conf.d/*.cfg.lua"

config里有什么需要设置的吗?

以下是我在 Strophe.js 中处理消息的方式:

function onLoginComplete(status) {
console.log(status);
if (status == Strophe.Status.CONNECTING) {
console.log('Strophe is connecting.');
} else if (status == Strophe.Status.CONNFAIL) {
console.log('Strophe failed to connect.');
} else if (status == Strophe.Status.DISCONNECTING) {
console.log('Strophe is disconnecting.');
} else if (status == Strophe.Status.DISCONNECTED) {
console.log('Strophe is disconnected.');
} else if (status == Strophe.Status.CONNECTED) {
console.log('Strophe is connected.');
connection.addHandler(onMessage, null, 'message', null, null, null);

if (!chat_room) {
// join to chatroom
}
}

/**
* on new message handler
**/
function onMessage(message) {
console.log(message);
var type = $(message).attr('type');
var body = $(message).find('body').text();
switch (type) {
case 'groupchat':
console.log(body);
// todo append message to the list
appendMessage(message);
break;
}
return true;
}

这是用户刚加入房间时的一条历史消息:

<message xmlns="jabber:client" type="groupchat"     to="subkhan@localhost/edff55f2-2980-4d01-bf65-0d2c0b011845"     from="test@conference.localhost/subkhan"><body>8</body><delay xmlns="urn:xmpp:delay" stamp="2017-04-12T02:54:48Z"></delay><x xmlns="jabber:x:delay" stamp="20170412T02:54:48"></x></message>

延迟有什么关系吗?

提前谢谢你。

最佳答案

事实证明,这段时间客户端已经获得了所有完整的消息历史记录,除了它转到 rawInput(data),而不是 onMessage() 处理程序。所以我只是删除处理程序并通过 rawInput(data) 处理传入的消息。

关于lua - Prosody muc 聊天记录不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43359598/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com