/** * Creates a ChatNote that will be mapped to the given chat session. * * @param sessionID the session id of a Chat Session. * @param note the chat note to add. * @throws XMPPException is thrown if an error occurs while adding the note. */ public void setNote(String sessionID, String note) throws XMPPException { note = ChatNotes.replace(note, "\n", "\\n"); note = StringUtils.escapeForXML(note); ChatNotes notes = new ChatNotes(); notes.setType(IQ.Type.SET); notes.setTo(workgroupJID); notes.setSessionID(sessionID); notes.setNotes(note); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(notes.getPacketID())); // Send the request connection.sendPacket(notes); IQ response = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } }
/** * Retrieves the ChatNote associated with a given chat session. * * @param sessionID the sessionID of the chat session. * @return the <code>ChatNote</code> associated with a given chat session. * @throws XMPPException if an error occurs while retrieving the ChatNote. */ public ChatNotes getNote(String sessionID) throws XMPPException { ChatNotes request = new ChatNotes(); request.setType(IQ.Type.GET); request.setTo(workgroupJID); request.setSessionID(sessionID); PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID())); connection.sendPacket(request); ChatNotes response = (ChatNotes)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } return response; }
/** * Retrieves the ChatNote associated with a given chat session. * * @param sessionID * the sessionID of the chat session. * @return the <code>ChatNote</code> associated with a given chat session. * @throws XMPPException * if an error occurs while retrieving the ChatNote. */ public ChatNotes getNote(String sessionID) throws XMPPException { ChatNotes request = new ChatNotes(); request.setType(IQ.Type.GET); request.setTo(workgroupJID); request.setSessionID(sessionID); PacketCollector collector = connection .createPacketCollector(new PacketIDFilter(request.getPacketID())); connection.sendPacket(request); ChatNotes response = (ChatNotes) collector .nextResult(SmackConfiguration.getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } return response; }
/** * Retrieves the ChatNote associated with a given chat session. * * @param sessionID the sessionID of the chat session. * @return the <code>ChatNote</code> associated with a given chat session. * @throws XMPPErrorException if an error occurs while retrieving the ChatNote. * @throws NoResponseException * @throws NotConnectedException */ public ChatNotes getNote(String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException { ChatNotes request = new ChatNotes(); request.setType(IQ.Type.get); request.setTo(workgroupJID); request.setSessionID(sessionID); ChatNotes response = (ChatNotes) connection.createPacketCollectorAndSend(request).nextResultOrThrow(); return response; }
/** * Creates a ChatNote that will be mapped to the given chat session. * * @param sessionID * the session id of a Chat Session. * @param note * the chat note to add. * @throws XMPPException * is thrown if an error occurs while adding the note. */ public void setNote(String sessionID, String note) throws XMPPException { note = ChatNotes.replace(note, "\n", "\\n"); note = StringUtils.escapeForXML(note); ChatNotes notes = new ChatNotes(); notes.setType(IQ.Type.SET); notes.setTo(workgroupJID); notes.setSessionID(sessionID); notes.setNotes(note); PacketCollector collector = connection .createPacketCollector(new PacketIDFilter(notes.getPacketID())); // Send the request connection.sendPacket(notes); IQ response = (IQ) collector.nextResult(SmackConfiguration .getPacketReplyTimeout()); // Cancel the collector. collector.cancel(); if (response == null) { throw new XMPPException("No response from server on status set."); } if (response.getError() != null) { throw new XMPPException(response.getError()); } }
/** * Creates a ChatNote that will be mapped to the given chat session. * * @param sessionID the session id of a Chat Session. * @param note the chat note to add. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public void setNote(String sessionID, String note) throws NoResponseException, XMPPErrorException, NotConnectedException { ChatNotes notes = new ChatNotes(); notes.setType(IQ.Type.set); notes.setTo(workgroupJID); notes.setSessionID(sessionID); notes.setNotes(note); connection.createPacketCollectorAndSend(notes).nextResultOrThrow(); }