2017-04-12 66 views
2

我嘗試使用韻律進行會議聊天,對於客戶端,我使用strophe.js。一切都很好,除了聊天曆史記錄顯示給用戶的一件事,當他們加入房間時並不完整。例如: 一個客戶端已發送的郵件的房間是這樣的:Prosody muc聊天記錄不完整

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 

但是,當新的客戶加入到房間裏,他們只得到的消息是這樣的:

1 
3 
5 
7 
9 

我試着在語義配置中設置max_history_messages = 10,並從客戶端設置maxstanzas = 10。但仍然如此。

這裏是我的配置文件

admins = { "[email protected]" } 
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" 

有什麼需要配置設置?

以下是我在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="[email protected]/edff55f2-2980-4d01-bf65-0d2c0b011845"  from="[email protected]/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> 

有什麼做的延遲?

預先感謝您。

回答

0

原來,所有這一次,客戶端已經獲取了所有完整的消息歷史記錄,除了它變爲rawInput(data),而不是onMessage()處理程序。所以我只是刪除處理程序,並通過rawInput(data)處理傳入的消息。