Java 类org.jivesoftware.smackx.time.packet.Time 实例源码

项目:Smack    文件:EntityTimeManager.java   
private EntityTimeManager(XMPPConnection connection) {
    super(connection);
    if (autoEnable)
        enable();

    connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, Type.get,
                    Mode.async) {
        @Override
        public IQ handleIQRequest(IQ iqRequest) {
            if (enabled) {
                return Time.createResponse(iqRequest);
            }
            else {
                return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.not_acceptable));
            }
        }
    });
}
项目:Smack    文件:EntityTimeManager.java   
public synchronized void enable() {
    if (enabled)
        return;
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
    sdm.addFeature(Time.NAMESPACE);
    enabled = true;
}
项目:Smack    文件:EntityTimeManager.java   
public synchronized void disable() {
    if (!enabled)
        return;
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
    sdm.removeFeature(Time.NAMESPACE);
    enabled = false;
}
项目:Smack    文件:EntityTimeManager.java   
public Time getTime(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
    if (!isTimeSupported(jid))
        return null;

    Time request = new Time();
    Time response = (Time) connection().createPacketCollectorAndSend(request).nextResultOrThrow();
    return response;
}
项目:Smack    文件:EntityTimeManager.java   
public boolean isTimeSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException  {
    return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, Time.NAMESPACE);
}
项目:Smack    文件:TimeProvider.java   
public TimeProvider() {
    super(Time.class);
}