オフラインメッセージが機能しないopenfire、smack、アンドロイドでチャットアプリケーションを試しています。両方のユーザーがオンラインの場合、メッセージを正しく送受信できます。しかし、ユーザAがオフラインで、ユーザBがメッセージを送信した場合、ユーザAはオンラインになった時点でBの送信メッセージを取得しません。以下のコードを使用してオフラインメッセージを取得します。スラックでオフラインメッセージが表示されない
新しいスレッド(){ ます。public void実行(){
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setSocketFactory(SocketFactory.getDefault())
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setServiceName("123.456.0.854")//service name
.setHost("123.456.0.854") // host name
.setPort(5222) //port
.setUsernameAndPassword("phone", "admin")
.setConnectTimeout(40000)
.setCompressionEnabled(false).build();
connection = new XMPPTCPConnection(config);
try {
connection.connect();
connection.login("phone", "admin");
Presence presence = new Presence(Presence.Type.available);
presence.setStatus("Available");
try {
connection.sendStanza(presence);
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
}
OfflineMessageManager offlineMessageManager = new OfflineMessageManager(connection);
try {
System.out.println("Count is " +offlineMessageManager.getMessageCount());
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}
}
}.start();