/** * Joins the chat room using the specified nickname. If already joined * using another nickname, this method will first leave the room and then * re-join using the new nickname. The default connection timeout for a reply * from the group chat server that the join succeeded will be used. After * joining the room, the room will decide the amount of history to send. * * @param nickname the nickname to use. * @throws NoResponseException * @throws XMPPErrorException if an error occurs joining the room. In particular, a * 401 error can occur if no password was provided and one is required; or a * 403 error can occur if the user is banned; or a * 404 error can occur if the room does not exist or is locked; or a * 407 error can occur if user is not on the member list; or a * 409 error can occur if someone is already in the group chat with the same nickname. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException * @throws NotAMucServiceException */ public void join(Resourcepart nickname) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAMucServiceException { MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname); join(builder.build()); }
/** * Joins the chat room using the specified nickname and password. If already joined * using another nickname, this method will first leave the room and then * re-join using the new nickname. The default connection timeout for a reply * from the group chat server that the join succeeded will be used. After * joining the room, the room will decide the amount of history to send.<p> * * A password is required when joining password protected rooms. If the room does * not require a password there is no need to provide one. * * @param nickname the nickname to use. * @param password the password to use. * @throws XMPPErrorException if an error occurs joining the room. In particular, a * 401 error can occur if no password was provided and one is required; or a * 403 error can occur if the user is banned; or a * 404 error can occur if the room does not exist or is locked; or a * 407 error can occur if user is not on the member list; or a * 409 error can occur if someone is already in the group chat with the same nickname. * @throws InterruptedException * @throws NotConnectedException * @throws NoResponseException if there was no response from the server. * @throws NotAMucServiceException */ public void join(Resourcepart nickname, String password) throws XMPPErrorException, InterruptedException, NoResponseException, NotConnectedException, NotAMucServiceException { MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname).withPassword( password); join(builder.build()); }
@SmackIntegrationTest public void mucJoinLeaveTest() throws XmppStringprepException, NotAMucServiceException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, MucNotJoinedException { EntityBareJid mucAddress = JidCreate.entityBareFrom(Localpart.from("smack-inttest-join-leave-" + randomString), mucService.getDomain()); MultiUserChat muc = mucManagerOne.getMultiUserChat(mucAddress); muc.join(Resourcepart.from("nick-one")); Presence reflectedLeavePresence = muc.leave(); MUCUser mucUser = MUCUser.from(reflectedLeavePresence); assertNotNull(mucUser); assertTrue(mucUser.getStatus().contains(MUCUser.Status.PRESENCE_TO_SELF_110)); }
handle.makeInstant(); mucAsSeenByTwo.join(Resourcepart.from("two-" + randomString));
MultiUserChat muc = new MultiUserChat(connection, "roomname@<server>"); muc.create("nickname1"); Form form = muc.getConfigurationForm(); Form submitForm = form.createAnswerForm(); for (Iterator fields = form.getFields();fields.hasNext();){ FormField field = (FormField) fields.next(); if(!FormField.TYPE_HIDDEN.equals(field.getType()) && field.getVariable()!= null){ submitForm.setDefaultAnswer(field.getVariable()); } } submitForm.setAnswer("muc#roomconfig_publicroom", true); muc.sendConfigurationForm(submitForm); muc.join("nickname1"); }catch (Exception e) { e.printStackTrace(); }
// Create a MultiUserChat using a XMPPConnection for a room MultiUserChat muc2 = new MultiUserChat(connection, "myFirstName@conference."+"Your HOST/Domain"); // User2 joins the new room // The room service will decide the amount of history to send muc2.join("testbot2");
MultiUserChat.addInvitationListener(conn3, new InvitationListener() { public void invitationReceived(XMPPConnection conn, String room, String inviter, String reason, String password) { // Reject the invitation MultiUserChat.decline(conn, room, inviter, "I'm busy right now"); //Accept the invitation MultiUserChat muc=new MultiUserChat(conn,room); muc.join(testNickName,password); }
UUID uid = UUID.randomUUID(); String chatRoomName = String.format("private-chat-%1s@%2s", uid, "groupchat.google.com"); MultiUserChat muc = new MultiUserChat(connection, chatRoomName); muc.join("My username");
MultiUserChat.addInvitationListener(connection, new InvitationListener() { @Override public void invitationReceived(Connection conn, String room, String inviter, String reason, String password, Message arg5) { MultiUserChat muc = new MultiUserChat(connection, room); try { muc.join(connection.getUser().substring(0, connection.getUser().indexOf("@"))); } catch (XMPPException e) { Log.d("Error","line 123 : "+e.toString()); } muc.addMessageListener(new ServiceGroupMessageListener(getApplicationContext())); } });
String room = "private-chat-" + UUID.randomUUID().toString(); room = room + "@groupchat.google.com"; MultiUserChat muc = new MultiUserChat(cc, room); muc.join("username", "password"); muc.invite("username", "hi");
room="private-chat-" + UUID.randomUUID().toString() + "@groupchat.google.com"; MultiUserChat muc = new MultiUserChat(connection, room); muc.join(userName); muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
synchronized void tryJoinChat(MultiUserChat chat) throws XMPPException { chat.join(getUserName()); }
public MultiUserChat joinChannelWithoutHashing(String name, String password) { MultiUserChat chat = new MultiUserChat(this, name); chatRooms.put(name, chat); try { chat.join(getUsername(), password); return chat; } catch (XMPPException.XMPPErrorException | SmackException e) { throw new IllegalStateException(e); } }
MultiUserChat muc = new MultiUserChat(mConnection, room_name); Log.d(TAG, "JOINING => " + room_name); DiscussionHistory history = new DiscussionHistory(); history.setMaxStanzas(0); muc.join(mNickName, null, history,SmackConfiguration.getDefaultPacketReplyTimeout());
final MultiUserChat muc = new MultiUserChat(connection, roomsName+ "@conference." + connection.getServiceName()); // The number of chat room services will decide to accept the // historical record // muc.create(roomsName); DiscussionHistory history = new DiscussionHistory(); history.setMaxStanzas(0); // history.setSince(new Date()); // Users to join in the chat room // if (user.equals("meet")) { // muc.invite("Kishan@54.76.159.35", "Invitation From Rajan"); muc.join(user, password, history, SmackConfiguration.getPacketReplyTimeout());
protected void tryToJoinChat() throws XMPPException { DiscussionHistory history = new DiscussionHistory(); history.setMaxStanzas(0); // use the same default value that the smack API uses internally long joinTimeout = SmackConfiguration.getPacketReplyTimeout(); chat.join(nickname, null, history, joinTimeout); if (logger.isDebugEnabled()) { logger.debug("joined groupchat '" + recipient + "'"); } }
MultiUserChat muc = new MultiUserChat(mConnection, room_name); Log.d(TAG, "JOINING => " + room_name); DiscussionHistory history = new DiscussionHistory(); if (mLastMessageDate == null) history.setMaxStanzas(300); else history.setSince(mLastMessageDate); //timestamp from your last message muc.join(mNickName, null, history, SmackConfiguration.getDefaultPacketReplyTimeout());
public void joinMultiUserChatRoom(String userName, String roomName) { // Get the MultiUserChatManager MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection); // Create a MultiUserChat using an XMPPConnection for a room MultiUserChat multiUserChat = manager.getMultiUserChat(roomName + "servername"); DiscussionHistory history = new DiscussionHistory(); history.setMaxStanzas(-1); try { multiUserChat.join(userName+"servername`enter code here`",userName, history, connection.getPacketReplyTimeout()); } catch (Exception e) { e.printStackTrace(); } }
@Override public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception { String room = sampler.getPropertyAsString(ROOM); String nick = sampler.getPropertyAsString(NICKNAME); res.setSamplerData("Join Room: " + room + "/" + nick); MultiUserChat muc = new MultiUserChat(sampler.getXMPPConnection(), room); muc.join(nick); return res; }
private void join(MultiUserChat chat) { try { assert connection.isConnected(); assert connection.isAuthenticated(); chat.addParticipantListener(new PresenceIndicator.PresenceListener()); chat.addParticipantListener(new PresenceListener()); chat.join(getUserName()); } catch (XMPPException ex) { XMPPLOG.log(Level.INFO, "Cannot join " + chat.getRoom(), ex); } }