use of org.jivesoftware.smackx.workgroup.packet.AgentInfo in project ecf by eclipse.
the class Agent method getName.
/**
* Return the agents name.
*
* @return - the agents name.
*/
public String getName() throws XMPPException {
AgentInfo agentInfo = new AgentInfo();
agentInfo.setType(IQ.Type.GET);
agentInfo.setTo(workgroupJID);
agentInfo.setFrom(getUser());
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(agentInfo.getPacketID()));
// Send the request
connection.sendPacket(agentInfo);
AgentInfo response = (AgentInfo) 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());
}
return response.getName();
}
use of org.jivesoftware.smackx.workgroup.packet.AgentInfo in project ecf by eclipse.
the class Agent method setName.
/**
* Changes the name of the agent in the server. The server may have this functionality
* disabled for all the agents or for this agent in particular. If the agent is not
* allowed to change his name then an exception will be thrown with a service_unavailable
* error code.
*
* @param newName the new name of the agent.
* @throws XMPPException if the agent is not allowed to change his name or no response was
* obtained from the server.
*/
public void setName(String newName) throws XMPPException {
AgentInfo agentInfo = new AgentInfo();
agentInfo.setType(IQ.Type.SET);
agentInfo.setTo(workgroupJID);
agentInfo.setFrom(getUser());
agentInfo.setName(newName);
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(agentInfo.getPacketID()));
// Send the request
connection.sendPacket(agentInfo);
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());
}
return;
}
use of org.jivesoftware.smackx.workgroup.packet.AgentInfo in project Smack by igniterealtime.
the class Agent method setName.
/**
* Changes the name of the agent in the server. The server may have this functionality
* disabled for all the agents or for this agent in particular. If the agent is not
* allowed to change his name then an exception will be thrown with a service_unavailable
* error code.
*
* @param newName the new name of the agent.
* @throws XMPPErrorException if there was an XMPP error returned.
* @throws NoResponseException if there was no response from the remote entity.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public void setName(String newName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
AgentInfo agentInfo = new AgentInfo();
agentInfo.setType(IQ.Type.set);
agentInfo.setTo(workgroupJID);
agentInfo.setFrom(getUser());
agentInfo.setName(newName);
connection.sendIqRequestAndWaitForResponse(agentInfo);
}
use of org.jivesoftware.smackx.workgroup.packet.AgentInfo in project Smack by igniterealtime.
the class Agent method getName.
/**
* Return the agents name.
*
* @return - the agents name.
* @throws XMPPErrorException if there was an XMPP error returned.
* @throws NoResponseException if there was no response from the remote entity.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public String getName() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
AgentInfo agentInfo = new AgentInfo();
agentInfo.setType(IQ.Type.get);
agentInfo.setTo(workgroupJID);
agentInfo.setFrom(getUser());
AgentInfo response = connection.sendIqRequestAndWaitForResponse(agentInfo);
return response.getName();
}
Aggregations