当前位置: 首页>>代码示例>>Java>>正文


Java MqttWireMessage类代码示例

本文整理汇总了Java中org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage的典型用法代码示例。如果您正苦于以下问题:Java MqttWireMessage类的具体用法?Java MqttWireMessage怎么用?Java MqttWireMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MqttWireMessage类属于org.eclipse.paho.client.mqttv3.internal.wire包,在下文中一共展示了MqttWireMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: markComplete

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
/**
 * Mark the token as complete and ready for users to be notified.
 *
 * @param msg response message. Optional - there are no response messages for some flows
 * @param ex  if there was a problem store the exception in the token.
 */
protected void markComplete(MqttWireMessage msg, MqttException ex) {
    final String methodName = "markComplete";
    //@TRACE 404=>key={0} response={1} excep={2}
    log.fine(className, methodName, "404", new Object[]{getKey(), msg, ex});

    synchronized (responseLock) {
        // ACK means that everything was OK, so mark the message for garbage collection.
        if (msg instanceof MqttAck) {
            this.message = null;
        }
        this.pendingComplete = true;
        this.response = msg;
        this.exception = ex;
    }
}
 
开发者ID:longkerdandy,项目名称:chii2mqtt,代码行数:22,代码来源:Token.java

示例2: restoreMessage

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
private MqttWireMessage restoreMessage(String key, MqttPersistable persistable) throws MqttException {
	final String methodName = "restoreMessage";
	MqttWireMessage message = null;

	try {
		message = MqttWireMessage.createWireMessage(persistable);
	}
	catch (MqttException ex) {
		//@TRACE 602=key={0} exception
		log.fine(CLASS_NAME, methodName, "602", new Object[] {key}, ex);
		if (ex.getCause() instanceof EOFException) {
			// Premature end-of-file means that the message is corrupted
			if (key != null) {
				persistence.remove(key);
			}
		}
		else {
			throw ex;
		}
	}
	//@TRACE 601=key={0} message={1}
	log.fine(CLASS_NAME, methodName, "601", new Object[]{key,message});
	return message;
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:25,代码来源:ClientState.java

示例3: notifyResult

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
protected void notifyResult(MqttWireMessage ack, MqttToken token, MqttException ex) {
	final String methodName = "notifyResult";
	// unblock any threads waiting on the token  
	token.internalTok.markComplete(ack, ex);
					
	// Let the user know an async operation has completed and then remove the token
	if (ack != null && ack instanceof MqttAck && !(ack instanceof MqttPubRec)) {
		//@TRACE 648=key{0}, msg={1}, excep={2}
		log.fine(CLASS_NAME,methodName, "648", new Object [] {token.internalTok.getKey(), ack, ex});
		callback.asyncOperationComplete(token);
	}
	// There are cases where there is no ack as the operation failed before 
	// an ack was received 
	if (ack == null ) {
		//@TRACE 649=key={0},excep={1}
		log.fine(CLASS_NAME,methodName, "649", new Object [] { token.internalTok.getKey(), ex});
		callback.asyncOperationComplete(token);
	}
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:20,代码来源:ClientState.java

示例4: markComplete

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
/**
 * Mark the token as complete and ready for users to be notified.
 * @param msg response message. Optional - there are no response messages for some flows
 * @param ex if there was a problem store the exception in the token.
 */
protected void markComplete(MqttWireMessage msg, MqttException ex) {
	final String methodName = "markComplete";
	//@TRACE 404=>key={0} response={1} excep={2}
	log.fine(CLASS_NAME,methodName,"404",new Object[]{getKey(),msg,ex});
			
	synchronized(responseLock) {
		// ACK means that everything was OK, so mark the message for garbage collection.
		if (msg instanceof MqttAck) {
			this.message = null;
		}
		this.pendingComplete = true;
		this.response = msg;
		this.exception = ex;
	}
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:21,代码来源:Token.java

示例5: getResponse

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
@Override
public MqttWireMessage getResponse() {
    if(connect2Token != null) return connect2Token.getResponse();
    if(disconnectToken != null) return disconnectToken.getResponse();
    if(connect1Token != null) return connect1Token.getResponse();
    return null;
}
 
开发者ID:SmartBear,项目名称:ready-mqtt-plugin,代码行数:8,代码来源:Client.java

示例6: handleRunException

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
private void handleRunException(MqttWireMessage message, Exception ex) {
    final String methodName = "handleRunException";
    //@TRACE 804=exception
    log.fine(className, methodName, "804", null, ex);
    MqttException mex;
    if (!(ex instanceof MqttException)) {
        mex = new MqttException(MqttException.REASON_CODE_CONNECTION_LOST, ex);
    } else {
        mex = (MqttException) ex;
    }

    running = false;
    clientComms.shutdownConnection(null, mex);
}
 
开发者ID:longkerdandy,项目名称:chii2mqtt,代码行数:15,代码来源:CommsSender.java

示例7: saveToken

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
protected void saveToken(MqttToken token, MqttWireMessage message) throws MqttException {
    final String methodName = "saveToken";

    synchronized (tokens) {
        if (closedResponse == null) {
            String key = message.getKey();
            //@TRACE 300=key={0} message={1}
            log.fine(className, methodName, "300", new Object[]{key, message});

            saveToken(token, key);
        } else {
            throw closedResponse;
        }
    }
}
 
开发者ID:longkerdandy,项目名称:chii2mqtt,代码行数:16,代码来源:CommsTokenStore.java

示例8: waitForCompletion

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
public void waitForCompletion(long timeout) throws MqttException {
    final String methodName = "waitForCompletion";
    //@TRACE 407=key={0} wait max={1} token={2}
    log.fine(className, methodName, "407", new Object[]{getKey(), new Long(timeout), this});

    MqttWireMessage resp = waitForResponse(timeout);
    if (resp == null && !completed) {
        //@TRACE 406=key={0} timed out token={1}
        log.fine(className, methodName, "406", new Object[]{getKey(), this});
        throw new MqttException(MqttException.REASON_CODE_CLIENT_TIMEOUT);
    }
    checkResult();
}
 
开发者ID:longkerdandy,项目名称:chii2mqtt,代码行数:14,代码来源:Token.java

示例9: waitForResponse

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
protected MqttWireMessage waitForResponse(long timeout) throws MqttException {
    final String methodName = "waitForResponse";
    synchronized (responseLock) {
        //@TRACE 400=>key={0} timeout={1} sent={2} completed={3} hasException={4} response={5} token={6}
        log.fine(className, methodName, "400", new Object[]{getKey(), new Long(timeout), new Boolean(sent), new Boolean(completed), (exception == null) ? "false" : "true", response, this}, exception);

        if (!this.completed) {
            if (this.exception == null) {
                try {
                    //@TRACE 408=key={0} wait max={1}
                    log.fine(className, methodName, "408", new Object[]{getKey(), new Long(timeout)});

                    if (timeout == -1) {
                        responseLock.wait();
                    } else {
                        responseLock.wait(timeout);
                    }
                } catch (InterruptedException e) {
                    exception = new MqttException(e);
                }
            }
            if (!this.completed) {
                if (this.exception != null) {
                    //@TRACE 401=failed with exception
                    log.fine(className, methodName, "401", null, exception);
                    throw exception;
                }
            }
        }
    }
    //@TRACE 402=key={0} response={1}
    log.fine(className, methodName, "402", new Object[]{getKey(), this.response});
    return this.response;
}
 
开发者ID:longkerdandy,项目名称:chii2mqtt,代码行数:35,代码来源:Token.java

示例10: insertInOrder

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
/**
 * Inserts a new message to the list, ensuring that list is ordered from lowest to highest in terms of the message id's.
 * @param list the list to insert the message into
 * @param newMsg the message to insert into the list
 */
private void insertInOrder(Vector list, MqttWireMessage newMsg) {
	int newMsgId = newMsg.getMessageId();
	for (int i = 0; i < list.size(); i++) {
		MqttWireMessage otherMsg = (MqttWireMessage) list.elementAt(i);
		int otherMsgId = otherMsg.getMessageId();
		if (otherMsgId > newMsgId) {
			list.insertElementAt(newMsg, i);
			return;
		}
	}
	list.addElement(newMsg);
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:18,代码来源:ClientState.java

示例11: notifySent

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
/**
 * Called by the CommsSender when a message has been sent
 * @param message
 */
protected void notifySent(MqttWireMessage message) {
	final String methodName = "notifySent";
	
	this.lastOutboundActivity = System.currentTimeMillis();
	//@TRACE 625=key={0}
	log.fine(CLASS_NAME,methodName,"625",new Object[]{message.getKey()});
	
	MqttToken token = tokenStore.getToken(message);
	token.internalTok.notifySent();
       if (message instanceof MqttPingReq) {
           synchronized (pingOutstandingLock) {
           	long time = System.currentTimeMillis();
               synchronized (pingOutstandingLock) {
               	lastPing = time;
               	pingOutstanding++;
               }
               //@TRACE 635=ping sent. pingOutstanding: {0}                                                                                                                                                                  
               log.fine(CLASS_NAME,methodName,"635",new Object[]{ new Integer(pingOutstanding)});
           }
       }
       else if (message instanceof MqttPublish) {
		if (((MqttPublish)message).getMessage().getQos() == 0) {
			// once a QoS 0 message is sent we can clean up its records straight away as
			// we won't be hearing about it again
			token.internalTok.markComplete(null, null);
			callback.asyncOperationComplete(token);
			decrementInFlight();
			releaseMessageId(message.getMessageId());
			tokenStore.removeToken(message);
			checkQuiesceLock();
		}
	}
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:38,代码来源:ClientState.java

示例12: handleRunException

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
private void handleRunException(MqttWireMessage message, Exception ex) {
	final String methodName = "handleRunException";
	//@TRACE 804=exception
	log.fine(CLASS_NAME,methodName,"804",null, ex);
	MqttException mex;
	if ( !(ex instanceof MqttException)) {
		mex = new MqttException(MqttException.REASON_CODE_CONNECTION_LOST, ex);
	} else {
		mex = (MqttException)ex;
	}

	running = false;
	clientComms.shutdownConnection(null, mex);
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:15,代码来源:CommsSender.java

示例13: saveToken

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
protected void saveToken(MqttToken token, MqttWireMessage message) throws MqttException {
	final String methodName = "saveToken";

	synchronized(tokens) {
		if (closedResponse == null) {
			String key = message.getKey();
			//@TRACE 300=key={0} message={1}
			log.fine(CLASS_NAME,methodName,"300",new Object[]{key, message});
			
			saveToken(token,key);
		} else {
			throw closedResponse;
		}
	}
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:16,代码来源:CommsTokenStore.java

示例14: waitForCompletion

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
public void waitForCompletion(long timeout) throws MqttException {
	final String methodName = "waitForCompletion";
	//@TRACE 407=key={0} wait max={1} token={2}
	log.fine(CLASS_NAME,methodName, "407",new Object[]{getKey(), new Long(timeout), this});

	MqttWireMessage resp = waitForResponse(timeout);
	if (resp == null && !completed) {
		//@TRACE 406=key={0} timed out token={1}
		log.fine(CLASS_NAME,methodName, "406",new Object[]{getKey(), this});
		exception = new MqttException(MqttException.REASON_CODE_CLIENT_TIMEOUT);
		throw exception;
	}
	checkResult();
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:15,代码来源:Token.java

示例15: waitForResponse

import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; //导入依赖的package包/类
protected MqttWireMessage waitForResponse(long timeout) throws MqttException {
	final String methodName = "waitForResponse";
	synchronized (responseLock) {
		//@TRACE 400=>key={0} timeout={1} sent={2} completed={3} hasException={4} response={5} token={6}
		log.fine(CLASS_NAME, methodName, "400",new Object[]{getKey(), new Long(timeout),new Boolean(sent),new Boolean(completed),(exception==null)?"false":"true",response,this},exception);

		while (!this.completed) {
			if (this.exception == null) {
				try {
					//@TRACE 408=key={0} wait max={1}
					log.fine(CLASS_NAME,methodName,"408",new Object[] {getKey(),new Long(timeout)});

					if (timeout <= 0) {
						responseLock.wait();
					} else {
						responseLock.wait(timeout);
					}
				} catch (InterruptedException e) {
					exception = new MqttException(e);
				}
			}
			if (!this.completed) {
				if (this.exception != null) {
					//@TRACE 401=failed with exception
					log.fine(CLASS_NAME,methodName,"401",null,exception);
					throw exception;
				}
				
				if (timeout > 0) {
					// time up and still not completed
					break;
				}
			}
		}
	}
	//@TRACE 402=key={0} response={1}
	log.fine(CLASS_NAME,methodName, "402",new Object[]{getKey(), this.response});
	return this.response;
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:40,代码来源:Token.java


注:本文中的org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。