2017-04-12 8 views
2

나는 prosody를 사용하여 회의 채팅을하려고하며 클라이언트의 경우 strophe.js를 사용합니다. 채팅 기록이 사용자에게 방에 들어 왔을 때 표시되는 채팅 기록이 완전하지 않은 경우를 제외하면 모든 기능이 훌륭합니다. 예를 들어이 같은프 로디 뮤 크 채팅 기록이 완전하지 않음

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 

그러나 새로운 클라이언트가 방에 가입 할 때, 그들은 단지 얻을 메시지 : 내가하려고

1 
3 
5 
7 
9 

을 한 클라이언트는 이미이 같은 방에 메시지를 보낸 프로 서디 구성에 max_history_messages = 10을 설정하고 클라이언트에서 maxstanzas = 10으로 설정하십시오. 그러나 여전히 동일합니다. 여기

는 설정에서 설정해야 뭔가 거기에 내 config 파일

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

클라이언트는 이미 으로 이동하는 것이 아니라 onMessage() 처리기가 아닌 모든 전체 메시지 기록을 가져옵니다. 그래서 난 그냥 처리기를 제거하고 rawInput(data) 통해 들어오는 메시지를 처리 ​​할 수 ​​있습니다.