[英]Delete Room Member from chat room using openfire server
I am new to openfire xmpp protocol. 我是openfire xmpp协议的新手。 I have been create chatroom successfully, now i want to do delete room member from room using REST API.
我已经成功创建了聊天室,现在我想使用REST API从会议室中删除会议室成员。 I has been refer the link mentioned here.
我一直在参考这里提到的链接 。 for delete room member for chat room.
用于删除聊天室的聊天室成员。
@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();
}
}
I got error 我有错误
Info: Response status::401
Info: Response msg::Unauthorized
here openfire console' log file 这里是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)
How to get resolve this issue? 如何解决这个问题?
If you use an older version of openfire you can not use JID in the path of your request. 如果您使用的是旧版的openfire,则无法在请求路径中使用JID。 (rajesh3@peacock-hp).
(rajesh3 @ peacock-hp)。 Try just rajesh3 instead.
请尝试只使用rajesh3。
In documentation it's possible to read this examples: 在文档中,可以阅读以下示例:
/chatrooms/{roomName}/{roles}/{name}
So your attempt it's to remove from "members" user "rajesh3@peacock-hp" on chatroom named " chatrooms ", i don't think this can work! 因此,您的尝试是从名为“ chatrooms ”的聊天室中的“成员”用户“ rajesh3 @ peacock-hp”中删除,我认为这不起作用!
You need the chatroom name (es: mychatroom@conference.peacock-hp
) and, before all, check if rajesh3@peacock-hp
it's already a member of this chatroom (check on Openfire admin to avoid errors: 您需要聊天室名称 (例如:
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")
If you want to remove rajesh3@peacock-hp in a global mode, set global
as roomName
如果要在全局模式下删除rajesh3 @ peacock-hp,请将
global
设置为roomName
EDIT: By the way, error reported it's about a plugin not loaded correctly, it has no effects on delete room member operation. 编辑:顺便说一句,错误报告它是关于一个插件未正确加载,它对删除房间成员操作没有影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.