[英]Delete Room Member from chat room using openfire server
我是openfire xmpp協議的新手。 我已經成功創建了聊天室,現在我想使用REST API從會議室中刪除會議室成員。 我一直在參考這里提到的鏈接 。 用於刪除聊天室的聊天室成員。
@RequestMapping(value = "leaveGroup", headers = {"ACCEPT=*/*"}, method = RequestMethod.POST, produces = "text/plain")
public @ResponseBody
String leaveGroup(HttpServletRequest request, HttpServletResponse response) {
getRestClient();
try {
List<String> memberList = restApiClient.getChatRoom("chatrooms").getMembers();
for (String string : memberList) {
System.out.println("user::" + string);
}
// http://example.org:9090/plugins/restapi/v1/chatrooms/chatrooms/members/rajesh3@peacock-hp
getJsonFromWEBService("http://192.168.168.24:9090/plugins/restapi/v1/chatrooms/chatrooms/members/rajesh3@peacock-hp");
//List<String> memberList1 = restApiClient.getChatRoom("chatrooms").getMembers().remove("rajesh3@peacock-hp");
} catch (Exception e) {
e.printStackTrace();
}
return "leaveGroup";
}
public void getJsonFromWEBService(String serviceURL) {
URL url;
try {
System.out.println("serviceURL::" + serviceURL);
url = new URL(serviceURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
System.out.println("conn::" + conn);
conn.setRequestProperty("Authorization", "Basic YWRtaW46MTIzNDU=");
conn.setRequestProperty("Content-Type", "application/xml");
conn.setRequestMethod("DELETE");
conn.setDoInput(true);
conn.setDoOutput(true);
System.out.println("status::"+conn.getResponseCode());
System.out.println("msg::"+conn.getResponseMessage());
System.out.println("req::"+conn.getRequestProperties());
//conn.getOutputStream().write(postDataBytes);
conn.disconnect();
System.out.println("end..........................................");
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
我有錯誤
Info: Response status::401
Info: Response msg::Unauthorized
這里是openfire控制台的日志文件
2016.07.23 12:14:41 org.jivesoftware.openfire.container.PluginManager - error in opening zip file
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130)
at org.jivesoftware.openfire.container.PluginManager$PluginMonitor.unzipPlugin(PluginManager.java:1069)
at org.jivesoftware.openfire.container.PluginManager$PluginMonitor.run(PluginManager.java:961)
如何解決這個問題?
如果您使用的是舊版的openfire,則無法在請求路徑中使用JID。 (rajesh3 @ peacock-hp)。 請嘗試只使用rajesh3。
在文檔中,可以閱讀以下示例:
/chatrooms/{roomName}/{roles}/{name}
因此,您的嘗試是從名為“ chatrooms ”的聊天室中的“成員”用戶“ rajesh3 @ peacock-hp”中刪除,我認為這不起作用!
您需要聊天室名稱 (例如: mychatroom@conference.peacock-hp
),並首先檢查rajesh3@peacock-hp
是否已經是此聊天室的成員 (請檢查Openfire管理員,以避免出現錯誤:
Admin console -> Uppertab: Group Chat -> select the service -> select your chatroom -> on left "Permissions" -> rajesh3@peacock-hp must figure out as "member")
如果要在全局模式下刪除rajesh3 @ peacock-hp,請將global
設置為roomName
編輯:順便說一句,錯誤報告它是關於一個插件未正確加載,它對刪除房間成員操作沒有影響。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.