├── .gitignore ├── .project ├── README.md ├── build.xml ├── libs ├── guava-17.0.jar └── jettison-1.1.jar ├── src ├── YunBaDemo.java ├── io │ └── yunba │ │ └── java │ │ ├── core │ │ ├── Constants.java │ │ ├── EventBusMessageDelivery.java │ │ ├── MQTTMessage.java │ │ ├── MQTTStack.java │ │ ├── MessageDelivery.java │ │ └── event │ │ │ ├── IEvent.java │ │ │ └── MessageArrivedEvent.java │ │ ├── manager │ │ └── YunBaManager.java │ │ └── util │ │ ├── CommonUtil.java │ │ └── MqttUtil.java └── org │ └── eclipse │ └── paho │ └── client │ └── mqttv3 │ ├── IMqttActionListener.java │ ├── IMqttAsyncClient.java │ ├── IMqttClient.java │ ├── IMqttDeliveryToken.java │ ├── IMqttToken.java │ ├── MqttAsyncClient.java │ ├── MqttCallback.java │ ├── MqttClient.java │ ├── MqttClientPersistence.java │ ├── MqttConnectOptions.java │ ├── MqttDeliveryToken.java │ ├── MqttException.java │ ├── MqttMessage.java │ ├── MqttPersistable.java │ ├── MqttPersistenceException.java │ ├── MqttSecurityException.java │ ├── MqttToken.java │ ├── MqttTopic.java │ ├── internal │ ├── ClientComms.java │ ├── ClientDefaults.java │ ├── ClientState.java │ ├── CommsCallback.java │ ├── CommsReceiver.java │ ├── CommsSender.java │ ├── CommsTokenStore.java │ ├── DestinationProvider.java │ ├── ExceptionHelper.java │ ├── FileLock.java │ ├── LocalNetworkModule.java │ ├── MessageCatalog.java │ ├── MqttPersistentData.java │ ├── NetworkModule.java │ ├── ResourceBundleCatalog.java │ ├── SSLNetworkModule.java │ ├── TCPNetworkModule.java │ ├── Token.java │ ├── nls │ │ ├── logcat.properties │ │ ├── logcat_cs.properties │ │ ├── logcat_de.properties │ │ ├── logcat_es.properties │ │ ├── logcat_fr.properties │ │ ├── logcat_hu.properties │ │ ├── logcat_it.properties │ │ ├── logcat_ja.properties │ │ ├── logcat_ko.properties │ │ ├── logcat_pl.properties │ │ ├── logcat_pt_BR.properties │ │ ├── logcat_ru.properties │ │ ├── logcat_zh_CN.properties │ │ ├── logcat_zh_TW.properties │ │ ├── messages.properties │ │ ├── messages_cs.properties │ │ ├── messages_de.properties │ │ ├── messages_es.properties │ │ ├── messages_fr.properties │ │ ├── messages_hu.properties │ │ ├── messages_it.properties │ │ ├── messages_ja.properties │ │ ├── messages_ko.properties │ │ ├── messages_pl.properties │ │ ├── messages_pt_BR.properties │ │ ├── messages_ru.properties │ │ ├── messages_zh_CN.properties │ │ └── messages_zh_TW.properties │ ├── security │ │ ├── SSLSocketFactoryFactory.java │ │ └── SimpleBase64Encoder.java │ └── wire │ │ ├── CountingInputStream.java │ │ ├── MqttAck.java │ │ ├── MqttConnack.java │ │ ├── MqttConnect.java │ │ ├── MqttDisconnect.java │ │ ├── MqttExpand.java │ │ ├── MqttExpandAck.java │ │ ├── MqttExpandPublish.java │ │ ├── MqttInputStream.java │ │ ├── MqttOutputStream.java │ │ ├── MqttPersistableWireMessage.java │ │ ├── MqttPingReq.java │ │ ├── MqttPingResp.java │ │ ├── MqttPubAck.java │ │ ├── MqttPubComp.java │ │ ├── MqttPubRec.java │ │ ├── MqttPubRel.java │ │ ├── MqttPublish.java │ │ ├── MqttReceivedMessage.java │ │ ├── MqttSuback.java │ │ ├── MqttSubscribe.java │ │ ├── MqttUnsubAck.java │ │ ├── MqttUnsubscribe.java │ │ ├── MqttWireMessage.java │ │ ├── MultiByteArrayInputStream.java │ │ └── MultiByteInteger.java │ ├── logging │ ├── JSR47Logger.java │ ├── Logger.java │ ├── LoggerFactory.java │ ├── MLogger.java │ ├── SimpleLogFormatter.java │ ├── jsr47min.properties │ └── package.html │ ├── package.html │ ├── persist │ ├── MemoryPersistence.java │ ├── MqttDefaultFilePersistence.java │ └── package.html │ └── util │ ├── Debug.java │ └── package.html └── yunba-java-sdk.jar /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /dist 3 | /bin 4 | /bin1 5 | /.settings 6 | .classpath 7 | .DS_Store 8 | .opts 9 | src/org/eclipse/paho/util/YunBaDemo.javA 10 | 11 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Yunba-Java-SDK 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 官方声明 2 | 3 | Java SDK 目前正在重构,此为第一版,用户可以试用自行下载试用,java sdk 的接口与 android 保持一致([android sdk API](https://yunba.io/docs/android_sdk_api_manual)) 4 | 5 | 对于自行修改 sdk 而导致的问题,云巴恕不提供技术支持。如果对于 sdk 有个性化需求,可以联系商务定制开发:xieting@yunba.io 6 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /libs/guava-17.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yunba/yunba-java-sdk/333ae6d7694fb70baa21c8abe29a88dc47342b5e/libs/guava-17.0.jar -------------------------------------------------------------------------------- /libs/jettison-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yunba/yunba-java-sdk/333ae6d7694fb70baa21c8abe29a88dc47342b5e/libs/jettison-1.1.jar -------------------------------------------------------------------------------- /src/io/yunba/java/core/Constants.java: -------------------------------------------------------------------------------- 1 | package io.yunba.java.core; 2 | 3 | 4 | public interface Constants { 5 | 6 | public static final String UTF_8 = "UTF-8"; 7 | public static final String TOPIC_SET_ALIAS = ",yali"; 8 | public static final String TOPIC_GET_ALIAS = ",yaliget"; 9 | } 10 | -------------------------------------------------------------------------------- /src/io/yunba/java/core/EventBusMessageDelivery.java: -------------------------------------------------------------------------------- 1 | package io.yunba.java.core; 2 | 3 | import io.yunba.java.core.event.MessageArrivedEvent; 4 | import io.yunba.java.manager.YunBaManager; 5 | 6 | public class EventBusMessageDelivery implements MessageDelivery { 7 | 8 | @Override 9 | public void postReceivedMessage(String topic, String entity) { 10 | YunBaManager.getEventBus().post( 11 | new MessageArrivedEvent(YunBaManager.MESSAGE_RECEIVED_ACTION, 12 | topic, entity)); 13 | } 14 | 15 | @Override 16 | public void postReceivedPresence(String topic, String presence) { 17 | YunBaManager.getEventBus().post( 18 | new MessageArrivedEvent(YunBaManager.PRESENCE_RECEIVED_ACTION, 19 | topic, presence)); 20 | } 21 | 22 | @Override 23 | public void postConnected() { 24 | YunBaManager.getEventBus().post( 25 | new MessageArrivedEvent(YunBaManager.MESSAGE_CONNECTED_ACTION, 26 | null, null)); 27 | } 28 | 29 | @Override 30 | public void postDisConnected() { 31 | YunBaManager.getEventBus().post( 32 | new MessageArrivedEvent(YunBaManager.MESSAGE_DISCONNECTED_ACTION, 33 | null, null)); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/io/yunba/java/core/MQTTMessage.java: -------------------------------------------------------------------------------- 1 | package io.yunba.java.core; 2 | 3 | import org.eclipse.paho.client.mqttv3.IMqttActionListener; 4 | 5 | public class MQTTMessage { 6 | 7 | public final static int TYPE_SUBSCRIBE = 1; 8 | public final static int TYPE_PUBLISH = 2; 9 | public final static int TYPE_UNSUBSCRIBE = 3; 10 | public final static int TYPE_EXPAND = 4; 11 | /** 12 | * 1 : subscribe 13 | * 2 : publish 14 | * 3 : unsubscribe 15 | * 4 : expand 16 | */ 17 | public int type; 18 | 19 | public int callbackId; 20 | 21 | public String topic; // maybe topic, alias, jsonobject 22 | 23 | public String msg; 24 | 25 | public int qos; 26 | 27 | public Object userContent; 28 | 29 | public byte EXPAND_COMMNAD; 30 | 31 | public IMqttActionListener callback; 32 | 33 | public MQTTMessage(int type, String topic, String msg, int qos, Object userContent, int callback, 34 | IMqttActionListener listener) { 35 | this.type = type; 36 | this.callbackId = callback; 37 | this.topic = topic; 38 | this.msg = msg; 39 | this.qos = qos; 40 | this.userContent = userContent; 41 | this.callback = listener; 42 | } 43 | 44 | 45 | @Override 46 | public String toString() { 47 | return "type = " + type + " topic = " + topic + " msg = " + topic + " userContent = " + userContent; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/io/yunba/java/core/MessageDelivery.java: -------------------------------------------------------------------------------- 1 | package io.yunba.java.core; 2 | 3 | public interface MessageDelivery { 4 | 5 | public void postReceivedMessage(String topic, String entity); 6 | 7 | public void postReceivedPresence(String topic, String presence); 8 | 9 | public void postConnected(); 10 | 11 | public void postDisConnected(); 12 | } 13 | -------------------------------------------------------------------------------- /src/io/yunba/java/core/event/IEvent.java: -------------------------------------------------------------------------------- 1 | package io.yunba.java.core.event; 2 | 3 | public interface IEvent { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/io/yunba/java/core/event/MessageArrivedEvent.java: -------------------------------------------------------------------------------- 1 | package io.yunba.java.core.event; 2 | 3 | public class MessageArrivedEvent implements IEvent{ 4 | private String mAction; 5 | private String mTopic; 6 | private String mMsg; 7 | 8 | public MessageArrivedEvent(String action, String topic, String msg) { 9 | this.mAction = action; 10 | this.mTopic = topic; 11 | this.mMsg = msg; 12 | } 13 | 14 | public String getAction() { 15 | return mAction; 16 | } 17 | 18 | public String getTopic() { 19 | return mTopic; 20 | } 21 | 22 | public String getMessage() { 23 | return mMsg; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/io/yunba/java/util/CommonUtil.java: -------------------------------------------------------------------------------- 1 | package io.yunba.java.util; 2 | 3 | import java.net.InetAddress; 4 | import java.net.UnknownHostException; 5 | import java.util.regex.Pattern; 6 | 7 | public class CommonUtil { 8 | private final static String HEX = "0123456789ABCDEF"; 9 | 10 | /** 11 | * will trim the string 12 | * 13 | * @param s 14 | * @return 15 | */ 16 | public static boolean isEmpty(String s) { 17 | if (null == s) 18 | return true; 19 | if (s.length() == 0) 20 | return true; 21 | if (s.trim().length() == 0) 22 | return true; 23 | return false; 24 | } 25 | 26 | public static String hostToIp(String host) { 27 | InetAddress address; 28 | try { 29 | address = InetAddress.getByName(host); 30 | return address.getHostAddress(); 31 | } catch (UnknownHostException e) { 32 | return null; 33 | } 34 | } 35 | 36 | public static byte DNS_REASON = 0; 37 | 38 | public static String join(T[] array, String cement) { 39 | StringBuilder builder = new StringBuilder(); 40 | 41 | if(array == null || array.length == 0) { 42 | return null; 43 | } 44 | for (T t : array) { 45 | builder.append(t).append(cement); 46 | } 47 | 48 | builder.delete(builder.length() - cement.length(), builder.length()); 49 | 50 | return builder.toString(); 51 | } 52 | 53 | private static final Pattern PATTERN = Pattern.compile( 54 | "^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); 55 | 56 | public static boolean validateIp(final String ip) { 57 | return PATTERN.matcher(ip).matches(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/IMqttActionListener.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.paho.client.mqttv3; 2 | 3 | /** 4 | * Implementors of this interface will be notified when an asynchronous action completes. 5 | * 6 | *

A listener is registered on an MqttToken and a token is associated 7 | * with an action like connect or publish. When used with tokens on the MqttAsyncClient 8 | * the listener will be called back on the MQTT clients thread. The listener will be informed 9 | * if the action succeeds or fails. It is important that the listener returns control quickly 10 | * otherwise the operation of the MQTT client will be stalled. 11 | *

12 | */ 13 | public interface IMqttActionListener { 14 | /** 15 | * This method is invoked when an action has completed successfully. 16 | * @param asyncActionToken associated with the action that has completed 17 | */ 18 | public void onSuccess(IMqttToken asyncActionToken ); 19 | /** 20 | * This method is invoked when an action fails. 21 | * If a client is disconnected while an action is in progress 22 | * onFailure will be called. For connections 23 | * that use clean session set to false, any QOS 1 and 2 messages that 24 | * are in the process of being delivered will be delivered to the requested 25 | * quality of service next time the client connects. 26 | * @param asyncActionToken associated with the action that has failed 27 | */ 28 | public void onFailure(IMqttToken asyncActionToken, Throwable exception); 29 | } 30 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/IMqttDeliveryToken.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.paho.client.mqttv3; 2 | /** 3 | * Provides a mechanism for tracking the delivery of a message 4 | * 5 | *

A subclass of IMqttToken that allows the delivery of a message to be tracked. 6 | * Unlike instances of IMqttToken delivery tokens can be used across connection 7 | * and client restarts. This enables the delivery of a messages to be tracked 8 | * after failures. There are two approaches 9 | *

17 | *

18 | * An action is in progress until either: 19 | *

27 | *

28 | * 29 | */ 30 | 31 | public interface IMqttDeliveryToken extends IMqttToken { 32 | /** 33 | * Returns the message associated with this token. 34 | *

Until the message has been delivered, the message being delivered will 35 | * be returned. Once the message has been delivered null will be 36 | * returned. 37 | * @return the message associated with this token or null if already delivered. 38 | * @throws MqttException if there was a problem completing retrieving the message 39 | */ 40 | public MqttMessage getMessage() throws MqttException; 41 | } 42 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/IMqttToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3; 13 | 14 | import org.codehaus.jettison.json.JSONObject; 15 | 16 | 17 | 18 | 19 | /** 20 | * Provides a mechanism for tracking the completion of an asynchronous task. 21 | * 22 | *

When using the asynchronous/non-blocking MQTT programming interface all 23 | * methods /operations that take any time and in particular those that involve 24 | * any network operation return control to the caller immediately. The operation 25 | * then proceeds to run in the background so as not to block the invoking thread. 26 | * An IMqttToken is used to track the state of the operation. An application can use the 27 | * token to wait for an operation to complete. A token is passed to callbacks 28 | * once the operation completes and provides context linking it to the original 29 | * request. A token is associated with a single operation.

30 | *

31 | * An action is in progress until either: 32 | *

36 | *

37 | * 38 | */ 39 | public interface IMqttToken { 40 | 41 | /** 42 | * Blocks the current thread until the action this token is associated with has 43 | * completed. 44 | * 45 | * @throws MqttException if there was a problem with the action associated with the token. 46 | * @see #waitForCompletion(long) 47 | */ 48 | public void waitForCompletion() throws MqttException; 49 | 50 | /** 51 | * Blocks the current thread until the action this token is associated with has 52 | * completed. 53 | *

The timeout specifies the maximum time it will block for. If the action 54 | * completes before the timeout then control returns immediately, if not 55 | * it will block until the timeout expires.

56 | *

If the action being tracked fails or the timeout expires an exception will 57 | * be thrown. In the event of a timeout the action may complete after timeout. 58 | *

59 | * 60 | * @param timeout the maximum amount of time to wait for, in milliseconds. 61 | * @throws MqttException if there was a problem with the action associated with the token. 62 | */ 63 | public void waitForCompletion(long timeout) throws MqttException; 64 | 65 | /** 66 | * Returns whether or not the action has finished. 67 | *

True will be returned both in the case where the action finished successfully 68 | * and in the case where it failed. If the action failed {@link #getException()} will 69 | * be non null. 70 | *

71 | */ 72 | public boolean isComplete(); 73 | 74 | /** 75 | * Returns an exception providing more detail if an operation failed 76 | *

While an action in in progress and when an action completes successfully 77 | * null will be returned. Certain errors like timeout or shutting down will not 78 | * set the exception as the action has not failed or completed at that time 79 | *

80 | * @return exception may return an exception if the operation failed. Null will be 81 | * returned while action is in progress and if action completes successfully. 82 | */ 83 | public MqttException getException(); 84 | 85 | /** 86 | * Register a listener to be notified when an action completes. 87 | *

Once a listener is registered it will be invoked when the action the token 88 | * is associated with either succeeds or fails. 89 | *

90 | * @param listener to be invoked once the action completes 91 | */ 92 | public void setActionCallback(IMqttActionListener listener); 93 | 94 | /** 95 | * Return the async listener for this token. 96 | * @return listener that is set on the token or null if a listener is not registered. 97 | */ 98 | public IMqttActionListener getActionCallback(); 99 | 100 | /** 101 | * Returns the MQTT client that is responsible for processing the asynchronous 102 | * action 103 | */ 104 | public IMqttAsyncClient getClient(); 105 | 106 | /** 107 | * Returns the topic string(s) for the action being tracked by this 108 | * token. If the action has not been initiated or the action has not 109 | * topic associated with it such as connect then null will be returned. 110 | * 111 | * @return the topic string(s) for the subscribe being tracked by this token or null 112 | */ 113 | public String[] getTopics(); 114 | 115 | /** 116 | * Store some context associated with an action. 117 | *

Allows the caller of an action to store some context that can be 118 | * accessed from within the ActionListener associated with the action. This 119 | * can be useful when the same ActionListener is associated with multiple 120 | * actions

121 | * @param userContext to associate with an action 122 | */ 123 | public void setUserContext(Object userContext); 124 | 125 | /** 126 | * Retrieve the context associated with an action. 127 | *

Allows the ActionListener associated with an action to retrieve any context 128 | * that was associated with the action when the action was invoked. If not 129 | * context was provided null is returned.

130 | 131 | * @return Object context associated with an action or null if there is none. 132 | */ 133 | public Object getUserContext(); 134 | 135 | /** 136 | * Returns the message ID of the message that is associated with the token. 137 | * A message id of zero will be returned for tokens associated with 138 | * connect, disconnect and ping operations as there can only ever 139 | * be one of these outstanding at a time. For other operations 140 | * the MQTT message id flowed over the network. 141 | */ 142 | public long getMessageId(); 143 | 144 | public String getAlias(); 145 | 146 | public void setAlias(String alias); 147 | 148 | public JSONObject getResult(); 149 | 150 | public void setResult(JSONObject result); 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/MqttCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3; 13 | 14 | 15 | /** 16 | * Enables an application to be notified when asynchronous 17 | * events related to the client occur. 18 | * Classes implementing this interface 19 | * can be registered on both types of client: {@link IMqttClient#setCallback(MqttCallback)} 20 | * and {@link IMqttAsyncClient#setCallback(MqttCallback)} 21 | */ 22 | public interface MqttCallback { 23 | /** 24 | * This method is called when the connection to the server is lost. 25 | * 26 | * @param cause the reason behind the loss of connection. 27 | */ 28 | public void connectionLost(Throwable cause); 29 | 30 | /** 31 | * This method is called when a message arrives from the server. 32 | * 33 | *

34 | * This method is invoked synchronously by the MQTT client. An 35 | * acknowledgement is not sent back to the server until this 36 | * method returns cleanly.

37 | *

38 | * If an implementation of this method throws an Exception, then the 39 | * client will be shut down. When the client is next re-connected, any QoS 40 | * 1 or 2 messages will be redelivered by the server.

41 | *

42 | * Any additional messages which arrive while an 43 | * implementation of this method is running, will build up in memory, and 44 | * will then back up on the network.

45 | *

46 | * If an application needs to persist data, then it 47 | * should ensure the data is persisted prior to returning from this method, as 48 | * after returning from this method, the message is considered to have been 49 | * delivered, and will not be reproducable.

50 | *

51 | * It is possible to send a new message within an implementation of this callback 52 | * (for example, a response to this message), but the implementation must not 53 | * disconnect the client, as it will be impossible to send an acknowledgement for 54 | * the message being processed, and a deadlock will occur.

55 | * 56 | * @param topic name of the topic on the message was published to 57 | * @param message the actual message. 58 | * @throws Exception if a terminal error has occurred, and the client should be 59 | * shut down. 60 | */ 61 | public void messageArrived(String topic, MqttMessage message) throws Exception; 62 | 63 | 64 | 65 | public void presenceMessageArrived(String topic, MqttMessage message) throws Exception; 66 | 67 | /** 68 | * Called when delivery for a message has been completed, and all 69 | * acknowledgements have been received. For QOS 0 messages it is 70 | * called once the message has been handed to the network for 71 | * delivery. For QOS 1 it is called when PUBACK is received and 72 | * for QOS 2 when PUBCOMP is received. The token will be the same 73 | * token as that returned when the message was published. 74 | * 75 | * @param token the delivery token associated with the message. 76 | */ 77 | public void deliveryComplete(IMqttDeliveryToken token); 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/MqttClientPersistence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3; 13 | 14 | import java.util.Enumeration; 15 | 16 | /** 17 | * Represents a persistent data store, used to store outbound and inbound messages while they 18 | * are in flight, enabling delivery to the QOS specified. You can specify an implementation 19 | * of this interface using {@link MqttClient#MqttClient(String, String, MqttClientPersistence)}, 20 | * which the {@link MqttClient} will use to persist QoS 1 and 2 messages. 21 | *

22 | * If the methods defined throw the MqttPersistenceException then the state of the data persisted 23 | * should remain as prior to the method being called. For example, if {@link #put(String, MqttPersistable)} 24 | * throws an exception at any point then the data will be assumed to not be in the persistent store. 25 | * Similarly if {@link #remove(String)} throws an exception then the data will be 26 | * assumed to still be held in the persistent store.

27 | *

28 | * It is up to the persistence interface to log any exceptions or error information 29 | * which may be required when diagnosing a persistence failure.

30 | */ 31 | public interface MqttClientPersistence { 32 | /** 33 | * Initialise the persistent store. 34 | * If a persistent store exists for this client ID then open it, otherwise 35 | * create a new one. If the persistent store is already open then just return. 36 | * An application may use the same client ID to connect to many different 37 | * servers, so the client ID in conjunction with the 38 | * connection will uniquely identify the persistence store required. 39 | * 40 | * @param clientId The client for which the persistent store should be opened. 41 | * @param serverURI The connection string as specified when the MQTT client instance was created. 42 | * @throws MqttPersistenceException if there was a problem opening the persistent store. 43 | */ 44 | public void open(String clientId, String serverURI) throws MqttPersistenceException; 45 | 46 | /** 47 | * Close the persistent store that was previously opened. 48 | * This will be called when a client application disconnects from the broker. 49 | * @throws MqttPersistenceException 50 | */ 51 | public void close() throws MqttPersistenceException; 52 | 53 | /** 54 | * Puts the specified data into the persistent store. 55 | * @param key the key for the data, which will be used later to retrieve it. 56 | * @param persistable the data to persist 57 | * @throws MqttPersistenceException if there was a problem putting the data 58 | * into the persistent store. 59 | */ 60 | public void put(String key, MqttPersistable persistable) throws MqttPersistenceException; 61 | 62 | /** 63 | * Gets the specified data out of the persistent store. 64 | * @param key the key for the data, which was used when originally saving it. 65 | * @return the un-persisted data 66 | * @throws MqttPersistenceException if there was a problem getting the data 67 | * from the persistent store. 68 | */ 69 | public MqttPersistable get(String key) throws MqttPersistenceException; 70 | 71 | /** 72 | * Remove the data for the specified key. 73 | */ 74 | public void remove(String key) throws MqttPersistenceException; 75 | 76 | /** 77 | * Returns an Enumeration over the keys in this persistent data store. 78 | * @return an enumeration of {@link String} objects. 79 | */ 80 | public Enumeration keys() throws MqttPersistenceException; 81 | 82 | /** 83 | * Clears persistence, so that it no longer contains any persisted data. 84 | */ 85 | public void clear() throws MqttPersistenceException; 86 | 87 | /** 88 | * Returns whether or not data is persisted using the specified key. 89 | * @param key the key for data, which was used when originally saving it. 90 | */ 91 | public boolean containsKey(String key) throws MqttPersistenceException; 92 | } 93 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/MqttDeliveryToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3; 13 | 14 | /** 15 | * Provides a mechanism to track the delivery progress of a message. 16 | * 17 | *

18 | * Used to track the the delivery progress of a message when a publish is 19 | * executed in a non-blocking manner (run in the background)

20 | * 21 | * @see MqttToken 22 | */ 23 | public class MqttDeliveryToken extends MqttToken implements IMqttDeliveryToken { 24 | 25 | 26 | public MqttDeliveryToken() { 27 | super(); 28 | } 29 | 30 | public MqttDeliveryToken(String logContext) { 31 | super(logContext); 32 | } 33 | 34 | /** 35 | * Returns the message associated with this token. 36 | *

Until the message has been delivered, the message being delivered will 37 | * be returned. Once the message has been delivered null will be 38 | * returned. 39 | * @return the message associated with this token or null if already delivered. 40 | * @throws MqttException if there was a problem completing retrieving the message 41 | */ 42 | public MqttMessage getMessage() throws MqttException { 43 | return internalTok.getMessage(); 44 | } 45 | 46 | protected void setMessage(MqttMessage msg) { 47 | internalTok.setMessage(msg); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/MqttPersistable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3; 13 | 14 | /** 15 | * Represents an object used to pass data to be persisted across the 16 | * {@link org.eclipse.paho.client.mqttv3.MqttClientPersistence MqttClientPersistence} 17 | * interface. 18 | *

19 | * When data is passed across the interface the header and payload are 20 | * separated, so that unnecessary message copies may be avoided. 21 | * For example, if a 10 MB payload was published it would be inefficient 22 | * to create a byte array a few bytes larger than 10 MB and copy the 23 | * MQTT message header and payload into a contiguous byte array.

24 | *

25 | * When the request to persist data is made a separate byte array and offset 26 | * is passed for the header and payload. Only the data between 27 | * offset and length need be persisted. 28 | * So for example, a message to be persisted consists of a header byte 29 | * array starting at offset 1 and length 4, plus a payload byte array 30 | * starting at offset 30 and length 40000. There are three ways in which 31 | * the persistence implementation may return data to the client on 32 | * recovery: 33 | *

48 | *

49 | */ 50 | public interface MqttPersistable { 51 | 52 | /** 53 | * Returns the header bytes in an array. 54 | * The bytes start at {@link #getHeaderOffset()} 55 | * and continue for {@link #getHeaderLength()}. 56 | * @return the header bytes. 57 | */ 58 | public byte[] getHeaderBytes() throws MqttPersistenceException; 59 | 60 | /** 61 | * Returns the length of the header. 62 | * @return the header length 63 | */ 64 | public int getHeaderLength() throws MqttPersistenceException; 65 | 66 | /** 67 | * Returns the offset of the header within the byte array returned by {@link #getHeaderBytes()}. 68 | * @return the header offset. 69 | * 70 | */ 71 | public int getHeaderOffset() throws MqttPersistenceException; 72 | 73 | /** 74 | * Returns the payload bytes in an array. 75 | * The bytes start at {@link #getPayloadOffset()} 76 | * and continue for {@link #getPayloadLength()}. 77 | * @return the payload bytes. 78 | */ 79 | public byte[] getPayloadBytes() throws MqttPersistenceException; 80 | 81 | /** 82 | * Returns the length of the payload. 83 | * @return the payload length. 84 | */ 85 | public int getPayloadLength() throws MqttPersistenceException; 86 | 87 | /** 88 | * Returns the offset of the payload within the byte array returned by {@link #getPayloadBytes()}. 89 | * @return the payload offset. 90 | * 91 | */ 92 | public int getPayloadOffset() throws MqttPersistenceException; 93 | } 94 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/MqttPersistenceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3; 13 | 14 | /** 15 | * This exception is thrown by the implementor of the persistence 16 | * interface if there is a problem reading or writing persistent data. 17 | */ 18 | public class MqttPersistenceException extends MqttException { 19 | private static final long serialVersionUID = 300L; 20 | 21 | /** Persistence is already being used by another client. */ 22 | public static final short REASON_CODE_PERSISTENCE_IN_USE = 32200; 23 | 24 | /** 25 | * Constructs a new MqttPersistenceException 26 | */ 27 | public MqttPersistenceException() { 28 | super(REASON_CODE_CLIENT_EXCEPTION); 29 | } 30 | 31 | /** 32 | * Constructs a new MqttPersistenceException with the specified code 33 | * as the underlying reason. 34 | * @param reasonCode the reason code for the exception. 35 | */ 36 | public MqttPersistenceException(int reasonCode) { 37 | super(reasonCode); 38 | } 39 | /** 40 | * Constructs a new MqttPersistenceException with the specified 41 | * Throwable as the underlying reason. 42 | * @param cause the underlying cause of the exception. 43 | */ 44 | public MqttPersistenceException(Throwable cause) { 45 | super(cause); 46 | } 47 | /** 48 | * Constructs a new MqttPersistenceException with the specified 49 | * Throwable as the underlying reason. 50 | * @param reason the reason code for the exception. 51 | * @param cause the underlying cause of the exception. 52 | */ 53 | public MqttPersistenceException(int reason, Throwable cause) { 54 | super(reason, cause); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/MqttSecurityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3; 13 | 14 | /** 15 | * Thrown when a client is not authorized to perform an operation, or 16 | * if there is a problem with the security configuration. 17 | */ 18 | public class MqttSecurityException extends MqttException { 19 | private static final long serialVersionUID = 300L; 20 | 21 | /** 22 | * Constructs a new MqttSecurityException with the specified code 23 | * as the underlying reason. 24 | * @param reasonCode the reason code for the exception. 25 | */ 26 | public MqttSecurityException(int reasonCode) { 27 | super(reasonCode); 28 | } 29 | 30 | /** 31 | * Constructs a new MqttSecurityException with the specified 32 | * Throwable as the underlying reason. 33 | * @param cause the underlying cause of the exception. 34 | */ 35 | public MqttSecurityException(Throwable cause) { 36 | super(cause); 37 | } 38 | /** 39 | * Constructs a new MqttSecurityException with the specified 40 | * code and Throwable as the underlying reason. 41 | * @param reasonCode the reason code for the exception. 42 | * @param cause the underlying cause of the exception. 43 | */ 44 | public MqttSecurityException(int reasonCode, Throwable cause) { 45 | super(reasonCode, cause); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/MqttToken.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.paho.client.mqttv3; 2 | 3 | import org.codehaus.jettison.json.JSONObject; 4 | import org.eclipse.paho.client.mqttv3.internal.Token; 5 | 6 | /** 7 | * Provides a mechanism for tracking the completion of an asynchronous action. 8 | *

9 | * A token that implements the ImqttToken interface is returned from all non-blocking 10 | * method with the exception of publish. 11 | *

12 | * 13 | * @see IMqttToken 14 | */ 15 | 16 | public class MqttToken implements IMqttToken { 17 | /** 18 | * A reference to the the class that provides most of the implementation of the 19 | * MqttToken. MQTT application programs must not use the internal class. 20 | */ 21 | public Token internalTok = null; 22 | 23 | public MqttToken() { 24 | } 25 | 26 | public MqttToken(String logContext) { 27 | internalTok = new Token(logContext); 28 | } 29 | 30 | public MqttException getException() { 31 | return internalTok.getException(); 32 | } 33 | 34 | public boolean isComplete() { 35 | return internalTok.isComplete(); 36 | } 37 | 38 | public void setActionCallback(IMqttActionListener listener) { 39 | internalTok.setActionCallback(listener); 40 | 41 | } 42 | public IMqttActionListener getActionCallback() { 43 | return internalTok.getActionCallback(); 44 | } 45 | 46 | public void waitForCompletion() throws MqttException { 47 | internalTok.waitForCompletion(-1); 48 | } 49 | 50 | public void waitForCompletion(long timeout) throws MqttException { 51 | internalTok.waitForCompletion(timeout); 52 | } 53 | 54 | public IMqttAsyncClient getClient() { 55 | return internalTok.getClient(); 56 | } 57 | 58 | public String[] getTopics() { 59 | return internalTok.getTopics(); 60 | } 61 | 62 | public Object getUserContext() { 63 | return internalTok.getUserContext(); 64 | } 65 | 66 | public void setUserContext(Object userContext) { 67 | internalTok.setUserContext(userContext); } 68 | 69 | public long getMessageId() { 70 | return internalTok.getMessageID(); 71 | } 72 | 73 | private String alias; 74 | 75 | @Override 76 | public String getAlias() { 77 | return alias; 78 | } 79 | 80 | @Override 81 | public void setAlias(String alias) { 82 | this.alias = alias; 83 | } 84 | 85 | private JSONObject result; 86 | 87 | @Override 88 | public JSONObject getResult() { 89 | return result; 90 | } 91 | 92 | @Override 93 | public void setResult(JSONObject result) { 94 | this.result = result; 95 | } 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/MqttTopic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3; 13 | 14 | import org.eclipse.paho.client.mqttv3.internal.ClientComms; 15 | import org.eclipse.paho.client.mqttv3.internal.wire.MqttPublish; 16 | 17 | /** 18 | * Represents a topic destination, used for publish/subscribe messaging. 19 | */ 20 | public class MqttTopic { 21 | 22 | private ClientComms comms; 23 | private String name; 24 | 25 | public MqttTopic(String name, ClientComms comms) { 26 | this.comms = comms; 27 | this.name = name; 28 | } 29 | 30 | /** 31 | * Publishes a message on the topic. This is a convenience method, which will 32 | * create a new {@link MqttMessage} object with a byte array payload and the 33 | * specified QoS, and then publish it. All other values in the 34 | * message will be set to the defaults. 35 | 36 | * @param payload the byte array to use as the payload 37 | * @param qos the Quality of Service. Valid values are 0, 1 or 2. 38 | * @param retained whether or not this message should be retained by the server. 39 | * @throws IllegalArgumentException if value of QoS is not 0, 1 or 2. 40 | * @see #publish(MqttMessage) 41 | * @see MqttMessage#setQos(int) 42 | * @see MqttMessage#setRetained(boolean) 43 | */ 44 | public MqttDeliveryToken publish(byte[] payload, int qos, boolean retained) throws MqttException, MqttPersistenceException { 45 | MqttMessage message = new MqttMessage(payload); 46 | message.setQos(qos); 47 | message.setRetained(retained); 48 | return this.publish(message); 49 | } 50 | 51 | /** 52 | * Publishes the specified message to this topic, but does not wait for delivery 53 | * of the message to complete. The returned {@link MqttDeliveryToken token} can be used 54 | * to track the delivery status of the message. Once this method has 55 | * returned cleanly, the message has been accepted for publication by the 56 | * client. Message delivery will be completed in the background when a connection 57 | * is available. 58 | * 59 | * @param message the message to publish 60 | * @return an MqttDeliveryToken for tracking the delivery of the message 61 | */ 62 | public MqttDeliveryToken publish(MqttMessage message) throws MqttException, MqttPersistenceException { 63 | MqttDeliveryToken token = new MqttDeliveryToken(comms.getClient().getClientId()); 64 | token.setMessage(message); 65 | comms.sendNoWait(createPublish(message), token); 66 | token.internalTok.waitUntilSent(); 67 | return token; 68 | } 69 | 70 | /** 71 | * Returns the name of the queue or topic. 72 | * 73 | * @return the name of this destination. 74 | */ 75 | public String getName() { 76 | return name; 77 | } 78 | 79 | /** 80 | * Create a PUBLISH packet from the specified message. 81 | */ 82 | private MqttPublish createPublish(MqttMessage message) { 83 | return new MqttPublish(this.getName(), message); 84 | } 85 | 86 | /** 87 | * Returns a string representation of this topic. 88 | * @return a string representation of this topic. 89 | */ 90 | public String toString() { 91 | return getName(); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/ClientDefaults.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | public class ClientDefaults { 15 | public static final int MAX_MSG_SIZE = 1024 * 1024 * 256; // 256 MB 16 | } 17 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/CommsSender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | 15 | import java.io.OutputStream; 16 | import java.text.SimpleDateFormat; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | import org.eclipse.paho.client.mqttv3.MqttToken; 20 | import org.eclipse.paho.client.mqttv3.internal.wire.MqttAck; 21 | import org.eclipse.paho.client.mqttv3.internal.wire.MqttOutputStream; 22 | import org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage; 23 | import org.eclipse.paho.client.mqttv3.logging.Logger; 24 | import org.eclipse.paho.client.mqttv3.logging.LoggerFactory; 25 | 26 | 27 | public class CommsSender implements Runnable { 28 | /** 29 | * Sends MQTT packets to the server on its own thread 30 | */ 31 | private boolean running = false; 32 | private Object lifecycle = new Object(); 33 | private ClientState clientState = null; 34 | private MqttOutputStream out; 35 | private ClientComms clientComms = null; 36 | private CommsTokenStore tokenStore = null; 37 | private Thread sendThread = null; 38 | 39 | private final static String className = "CommsSender"; 40 | private Logger log = LoggerFactory.getLogger(LoggerFactory.MQTT_CLIENT_MSG_CAT, className); 41 | 42 | public CommsSender(ClientComms clientComms, ClientState clientState, CommsTokenStore tokenStore, OutputStream out) { 43 | this.out = new MqttOutputStream(out); 44 | this.clientComms = clientComms; 45 | this.clientState = clientState; 46 | this.tokenStore = tokenStore; 47 | log.setResourceName(clientComms.getClient().getClientId()); 48 | } 49 | 50 | /** 51 | * Starts up the Sender thread. 52 | */ 53 | public void start(String threadName) { 54 | synchronized (lifecycle) { 55 | if (running == false) { 56 | running = true; 57 | sendThread = new Thread(this, threadName); 58 | sendThread.start(); 59 | } 60 | } 61 | } 62 | 63 | /** 64 | * Stops the Sender's thread. This call will block. 65 | */ 66 | public void stop() { 67 | final String methodName = "stop"; 68 | 69 | synchronized (lifecycle) { 70 | //@TRACE 800=stopping sender 71 | log.fine(className,methodName,"800"); 72 | if (running) { 73 | running = false; 74 | if (!Thread.currentThread().equals(sendThread)) { 75 | try { 76 | // first notify get routine to finish 77 | clientState.notifyQueueLock(); 78 | // Wait for the thread to finish. 79 | sendThread.join(); 80 | } 81 | catch (InterruptedException ex) { 82 | } 83 | } 84 | } 85 | sendThread=null; 86 | //@TRACE 801=stopped 87 | log.fine(className,methodName,"801"); 88 | } 89 | } 90 | 91 | 92 | //force destory the thread 93 | public void destory() { 94 | running = false; 95 | try { 96 | sendThread.interrupt(); 97 | } catch (Exception e) { 98 | //YLogger.e("CommsSender", "destory", e); 99 | } 100 | sendThread = null; 101 | } 102 | 103 | public void run() { 104 | final String methodName = "run"; 105 | MqttWireMessage message = null; 106 | while (running && (out != null)) { 107 | try { 108 | message = clientState.get(); 109 | if (message != null) { 110 | SimpleDateFormat time_formatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS"); 111 | String current_time_str = time_formatter.format(System.currentTimeMillis()); 112 | System.out.println(current_time_str + " : Send msg to server: msgId = " + message.getKey() + " key = " + message.getTypeStr()); 113 | //@TRACE 802=network send key={0} msg={1} 114 | log.fine(className,methodName,"802", new Object[] {message.getKey(),message}); 115 | 116 | if (message instanceof MqttAck) { 117 | out.write(message); 118 | out.flush(); 119 | } else { 120 | MqttToken token = tokenStore.getToken(message); 121 | // While quiescing the tokenstore can be cleared so need 122 | // to check for null for the case where clear occurs 123 | // while trying to send a message. 124 | if (token != null) { 125 | synchronized (token) { 126 | out.write(message); 127 | out.flush(); 128 | clientState.notifySent(message); 129 | } 130 | } else { 131 | //YLogger.e(className, "null token :" + "msgId = " + message.getKey() + " key = " + message.getType()); 132 | } 133 | } 134 | } else { // null message 135 | //@TRACE 803=get message returned null, stopping} 136 | log.fine(className,methodName,"803"); 137 | 138 | running = false; 139 | clientComms.shutdownConnection(null, new MqttException(MqttException.REASON_CODE_CLIENT_TIMEOUT)); 140 | } 141 | } catch (MqttException me) { 142 | // YLogger.e(className, methodName, me); 143 | handleRunException(message, me); 144 | } catch (Throwable ex) { 145 | // YLogger.e(className, methodName, ex); 146 | handleRunException(message, ex); 147 | } 148 | } // end while 149 | 150 | //@TRACE 805=< 151 | log.fine(className, methodName,"805"); 152 | 153 | } 154 | 155 | private void handleRunException(MqttWireMessage message, Throwable ex) { 156 | final String methodName = "handleRunException"; 157 | //@TRACE 804=exception 158 | //log.fine(className,methodName,"804",null, ex); 159 | //YLogger.d(className, methodName); 160 | MqttException mex; 161 | if ( !(ex instanceof MqttException)) { 162 | mex = new MqttException(MqttException.REASON_CODE_CONNECTION_LOST, ex); 163 | } else { 164 | mex = (MqttException)ex; 165 | } 166 | 167 | running = false; 168 | clientComms.shutdownConnection(null, mex); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/DestinationProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | import org.eclipse.paho.client.mqttv3.MqttTopic; 15 | 16 | /** 17 | * This interface exists to act as a common type for 18 | * MqttClient and MqttMIDPClient so they can be passed to 19 | * ClientComms without either client class need to know 20 | * about the other. 21 | * Specifically, this allows the MIDP client to work 22 | * without the non-MIDP MqttClient/MqttConnectOptions 23 | * classes being present. 24 | */ 25 | public interface DestinationProvider { 26 | public MqttTopic getTopic(String topic); 27 | } 28 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/ExceptionHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | import org.eclipse.paho.client.mqttv3.MqttException; 15 | import org.eclipse.paho.client.mqttv3.MqttSecurityException; 16 | 17 | /** 18 | * Utility class to help create exceptions of the correct type. 19 | */ 20 | public class ExceptionHelper { 21 | public static MqttException createMqttException(int reasonCode) { 22 | if ((reasonCode == MqttException.REASON_CODE_FAILED_AUTHENTICATION) || 23 | (reasonCode == MqttException.REASON_CODE_NOT_AUTHORIZED)) { 24 | return new MqttSecurityException(reasonCode); 25 | } 26 | 27 | return new MqttException(reasonCode); 28 | } 29 | 30 | public static MqttException createMqttException(Throwable cause) { 31 | if (cause.getClass().getName().equals("java.security.GeneralSecurityException")) { 32 | return new MqttSecurityException(cause); 33 | } 34 | return new MqttException(cause); 35 | } 36 | 37 | /** 38 | * Returns whether or not the specified class is available to the current 39 | * class loader. This is used to protect the code against using Java SE 40 | * APIs on Java ME. 41 | */ 42 | public static boolean isClassAvailable(String className) { 43 | boolean result = false; 44 | try { 45 | Class.forName(className); 46 | result = true; 47 | } 48 | catch (ClassNotFoundException ex) { 49 | } 50 | return result; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/FileLock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | /** 14 | * FileLock - used to obtain a lock that can be used to prevent other MQTT clients 15 | * using the same persistent store. If the lock is already held then an exception 16 | * is thrown. 17 | * 18 | * Some Java runtimes such as JME MIDP do not support file locking or even 19 | * the Java classes that support locking. The class is coded to both compile 20 | * and work on all Java runtimes. In Java runtimes that do not support 21 | * locking it will look as though a lock has been obtained but in reality 22 | * no lock has been obtained. 23 | */ 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.io.RandomAccessFile; 27 | import java.lang.reflect.Method; 28 | 29 | public class FileLock { 30 | private File lockFile; 31 | private RandomAccessFile file; 32 | private Object fileLock; 33 | 34 | /** 35 | * Creates an NIO FileLock on the specified file if on a suitable Java runtime. 36 | * @param clientDir the a File of the directory to contain the lock file. 37 | * @param lockFilename name of the the file to lock 38 | * @throws Exception if the lock could not be obtained for any reason 39 | */ 40 | public FileLock(File clientDir, String lockFilename) throws Exception { 41 | // Create a file to obtain a lock on. 42 | lockFile = new File(clientDir,lockFilename); 43 | if (ExceptionHelper.isClassAvailable("java.nio.channels.FileLock")) { 44 | try { 45 | this.file = new RandomAccessFile(lockFile,"rw"); 46 | Method m = file.getClass().getMethod("getChannel",new Class[]{}); 47 | Object channel = m.invoke(file,new Object[]{}); 48 | m = channel.getClass().getMethod("tryLock",new Class[]{}); 49 | this.fileLock = m.invoke(channel, new Object[]{}); 50 | } catch(NoSuchMethodException nsme) { 51 | this.fileLock = null; 52 | } catch(IllegalArgumentException iae) { 53 | this.fileLock = null; 54 | } catch(IllegalAccessException iae) { 55 | this.fileLock = null; 56 | } 57 | if (fileLock == null) { 58 | // Lock not obtained 59 | release(); 60 | throw new Exception("Problem obtaining file lock"); 61 | } 62 | } 63 | } 64 | 65 | /** 66 | * Releases the lock. 67 | */ 68 | public void release() { 69 | try { 70 | if (fileLock != null) { 71 | Method m = fileLock.getClass().getMethod("release",new Class[]{}); 72 | m.invoke(fileLock, new Object[]{}); 73 | fileLock = null; 74 | } 75 | } catch (Exception e) { 76 | // Ignore exceptions 77 | } 78 | if (file != null) { 79 | try { 80 | file.close(); 81 | } catch (IOException e) { 82 | } 83 | file = null; 84 | } 85 | 86 | if (lockFile != null && lockFile.exists()) { 87 | lockFile.delete(); 88 | } 89 | lockFile = null; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/LocalNetworkModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.io.OutputStream; 17 | import java.lang.reflect.Method; 18 | 19 | import org.eclipse.paho.client.mqttv3.MqttException; 20 | 21 | 22 | /** 23 | * Special comms class that allows an MQTT client to use a non TCP / optimised 24 | * mechanism to talk to an MQTT server when running in the same JRE instance as the 25 | * MQTT server. 26 | * 27 | * This class checks for the existence of the optimised comms adatper class i.e. the one 28 | * that provides the optimised communication mechanism. If not available the request 29 | * to connect using the optimised mechanism is rejected. 30 | * 31 | * The only known server that implements this is the microbroker:- an MQTT server that 32 | * ships with a number of IBM products. 33 | */ 34 | public class LocalNetworkModule implements NetworkModule { 35 | private Class LocalListener; 36 | private String brokerName; 37 | private Object localAdapter; 38 | 39 | public LocalNetworkModule(String brokerName) { 40 | this.brokerName = brokerName; 41 | } 42 | 43 | public void start() throws IOException, MqttException{ 44 | if (!ExceptionHelper.isClassAvailable("com.ibm.mqttdirect.modules.local.bindings.LocalListener")) { 45 | throw ExceptionHelper.createMqttException(MqttException.REASON_CODE_SERVER_CONNECT_ERROR); 46 | } 47 | try { 48 | LocalListener = Class.forName("com.ibm.mqttdirect.modules.local.bindings.LocalListener"); 49 | Method connect_m = LocalListener.getMethod("connect", new Class[]{ java.lang.String.class }); 50 | localAdapter = connect_m.invoke(null,new Object[]{ brokerName }); 51 | } catch(Exception e) { 52 | } 53 | if(localAdapter == null) { 54 | throw ExceptionHelper.createMqttException(MqttException.REASON_CODE_SERVER_CONNECT_ERROR); 55 | } 56 | } 57 | 58 | public InputStream getInputStream() throws IOException { 59 | InputStream stream = null; 60 | try { 61 | Method m = LocalListener.getMethod("getClientInputStream",new Class[]{}); 62 | stream = (InputStream)m.invoke(this.localAdapter,new Object[]{}); 63 | } catch(Exception e) { 64 | } 65 | return stream; 66 | } 67 | 68 | public OutputStream getOutputStream() throws IOException { 69 | OutputStream stream = null; 70 | try { 71 | Method m = LocalListener.getMethod("getClientOutputStream",new Class[]{}); 72 | stream = (OutputStream)m.invoke(this.localAdapter,new Object[]{}); 73 | } catch(Exception e) { 74 | } 75 | return stream; 76 | } 77 | 78 | public void stop() throws IOException { 79 | if (localAdapter != null) { 80 | try { 81 | Method m = LocalListener.getMethod("close",new Class[]{}); 82 | m.invoke(this.localAdapter,new Object[]{}); 83 | } catch(Exception e) { 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/MessageCatalog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | /** 15 | * Catalog of human readable error messages. 16 | */ 17 | public abstract class MessageCatalog { 18 | private static MessageCatalog INSTANCE = null; 19 | 20 | public static final String getMessage(int id) { 21 | try { 22 | if (INSTANCE == null) { 23 | if (ExceptionHelper.isClassAvailable("java.util.ResourceBundle")) { 24 | try { 25 | // Hide this class reference behind reflection so that the class does not need to 26 | // be present when compiled on midp 27 | INSTANCE = (MessageCatalog)Class.forName("org.eclipse.paho.client.mqttv3.internal.ResourceBundleCatalog").newInstance(); 28 | } catch (Exception e) { 29 | return ""; 30 | } 31 | } else if (ExceptionHelper.isClassAvailable("org.eclipse.paho.client.mqttv3.internal.MIDPCatalog")){ 32 | try { 33 | INSTANCE = (MessageCatalog)Class.forName("org.eclipse.paho.client.mqttv3.internal.MIDPCatalog").newInstance(); 34 | } catch (Exception e) { 35 | return ""; 36 | } 37 | } 38 | } 39 | return INSTANCE.getLocalizedMessage(id); 40 | } catch(Exception e) { 41 | return ""; 42 | } 43 | } 44 | 45 | protected abstract String getLocalizedMessage(int id); 46 | } 47 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/MqttPersistentData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | import org.eclipse.paho.client.mqttv3.MqttPersistable; 15 | 16 | public class MqttPersistentData implements MqttPersistable { 17 | // Message key 18 | private String key = null; 19 | 20 | // Message header 21 | private byte[] header = null; 22 | private int hOffset = 0; 23 | private int hLength = 0; 24 | 25 | // Message payload 26 | private byte[] payload = null; 27 | private int pOffset = 0; 28 | private int pLength = 0; 29 | 30 | /** 31 | * Construct a data object to pass across the MQTT client persistence 32 | * interface.
33 | * When this Object is passed to the persistence implementation the key is 34 | * used by the client to identify the persisted data to which further 35 | * update or deletion requests are targeted.
36 | * When this Object is created for returning to the client when it is 37 | * recovering its state from persistence the key is not required to be set. 38 | * The client can determine the key from the data. 39 | * @param key The key which identifies this data 40 | * @param header The message header 41 | * @param hOffset The start offset of the header bytes in header. 42 | * @param hLength The length of the header in the header bytes array. 43 | * @param payload The message payload 44 | * @param pOffset The start offset of the payload bytes in payload. 45 | * @param pLength The length of the payload in the payload bytes array 46 | * when persisting the message. 47 | */ 48 | public MqttPersistentData( String key, 49 | byte[] header, 50 | int hOffset, 51 | int hLength, 52 | byte[] payload, 53 | int pOffset, 54 | int pLength) { 55 | this.key = key; 56 | this.header = header; 57 | this.hOffset = hOffset; 58 | this.hLength = hLength; 59 | this.payload = payload; 60 | this.pOffset = pOffset; 61 | this.pLength = pLength; 62 | } 63 | 64 | public String getKey() { 65 | return key; 66 | } 67 | 68 | public byte[] getHeaderBytes() { 69 | return header; 70 | } 71 | 72 | public int getHeaderLength() { 73 | return hLength; 74 | } 75 | 76 | public int getHeaderOffset() { 77 | return hOffset; 78 | } 79 | 80 | public byte[] getPayloadBytes() { 81 | return payload; 82 | } 83 | 84 | public int getPayloadLength() { 85 | if ( payload == null ) { 86 | return 0; 87 | } 88 | return pLength; 89 | } 90 | 91 | public int getPayloadOffset() { 92 | return pOffset; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/NetworkModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.io.OutputStream; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | 20 | 21 | public interface NetworkModule { 22 | public void start() throws IOException, MqttException; 23 | 24 | public InputStream getInputStream() throws IOException; 25 | 26 | public OutputStream getOutputStream() throws IOException; 27 | 28 | public void stop() throws IOException; 29 | } 30 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/ResourceBundleCatalog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | import java.util.MissingResourceException; 15 | import java.util.ResourceBundle; 16 | 17 | public class ResourceBundleCatalog extends MessageCatalog { 18 | 19 | private ResourceBundle bundle; 20 | 21 | public ResourceBundleCatalog() throws Exception { 22 | bundle = ResourceBundle.getBundle("org.eclipse.paho.client.mqttv3.internal.nls.messages"); 23 | } 24 | 25 | protected String getLocalizedMessage(int id) { 26 | try { 27 | return bundle.getString(Integer.toString(id)); 28 | } catch(Exception mre) { 29 | return "MqttException"; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/SSLNetworkModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | import java.io.IOException; 15 | 16 | import javax.net.ssl.SSLSocket; 17 | import javax.net.ssl.SSLSocketFactory; 18 | 19 | import org.eclipse.paho.client.mqttv3.MqttException; 20 | import org.eclipse.paho.client.mqttv3.logging.Logger; 21 | import org.eclipse.paho.client.mqttv3.logging.LoggerFactory; 22 | 23 | /** 24 | * A network module for connecting over SSL. 25 | */ 26 | public class SSLNetworkModule extends TCPNetworkModule { 27 | private String[] enabledCiphers; 28 | private int handshakeTimeoutSecs; 29 | 30 | final static String className = SSLNetworkModule.class.getName(); 31 | Logger log = LoggerFactory.getLogger(LoggerFactory.MQTT_CLIENT_MSG_CAT,className); 32 | 33 | /** 34 | * Constructs a new SSLNetworkModule using the specified host and 35 | * port. The supplied SSLSocketFactory is used to supply the network 36 | * socket. 37 | */ 38 | public SSLNetworkModule(SSLSocketFactory factory, String host, int port, String resourceContext) { 39 | super(factory, host, port, resourceContext); 40 | log.setResourceName(resourceContext); 41 | } 42 | 43 | /** 44 | * Returns the enabled cipher suites. 45 | */ 46 | public String[] getEnabledCiphers() { 47 | return enabledCiphers; 48 | } 49 | 50 | /** 51 | * Sets the enabled cipher suites on the underlying network socket. 52 | */ 53 | public void setEnabledCiphers(String[] enabledCiphers) { 54 | final String methodName = "setEnabledCiphers"; 55 | this.enabledCiphers = enabledCiphers; 56 | if ((socket != null) && (enabledCiphers != null)) { 57 | if (log.isLoggable(Logger.FINE)) { 58 | String ciphers = ""; 59 | for (int i=0;i0) { 61 | ciphers+=","; 62 | } 63 | ciphers+=enabledCiphers[i]; 64 | } 65 | //@TRACE 260=setEnabledCiphers ciphers={0} 66 | log.fine(className,methodName,"260",new Object[]{ciphers}); 67 | } 68 | ((SSLSocket) socket).setEnabledCipherSuites(enabledCiphers); 69 | } 70 | } 71 | 72 | public void setSSLhandshakeTimeout(int timeout) { 73 | this.handshakeTimeoutSecs = timeout; 74 | } 75 | 76 | public void start() throws IOException, MqttException { 77 | super.start(); 78 | setEnabledCiphers(enabledCiphers); 79 | int soTimeout = socket.getSoTimeout(); 80 | if ( soTimeout == 0 ) { 81 | // RTC 765: Set a timeout to avoid the SSL handshake being blocked indefinitely 82 | socket.setSoTimeout(this.handshakeTimeoutSecs*1000); 83 | } 84 | ((SSLSocket)socket).startHandshake(); 85 | // reset timeout to default value 86 | socket.setSoTimeout(soTimeout); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/TCPNetworkModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal; 13 | 14 | 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | import java.io.OutputStream; 18 | import java.net.ConnectException; 19 | import java.net.InetSocketAddress; 20 | import java.net.Socket; 21 | import java.net.SocketAddress; 22 | 23 | import javax.net.SocketFactory; 24 | 25 | import org.eclipse.paho.client.mqttv3.MqttException; 26 | import org.eclipse.paho.client.mqttv3.logging.Logger; 27 | import org.eclipse.paho.client.mqttv3.logging.LoggerFactory; 28 | 29 | /** 30 | * A network module for connecting over TCP. 31 | */ 32 | public class TCPNetworkModule implements NetworkModule { 33 | protected Socket socket; 34 | private SocketFactory factory; 35 | private String host; 36 | private int port; 37 | private int conTimeout; 38 | 39 | final static String className = TCPNetworkModule.class.getName(); 40 | Logger log = LoggerFactory.getLogger(LoggerFactory.MQTT_CLIENT_MSG_CAT,className); 41 | 42 | /** 43 | * Constructs a new TCPNetworkModule using the specified host and 44 | * port. The supplied SocketFactory is used to supply the network 45 | * socket. 46 | */ 47 | public TCPNetworkModule(SocketFactory factory, String host, int port, String resourceContext) { 48 | log.setResourceName(resourceContext); 49 | this.factory = factory; 50 | this.host = host; 51 | this.port = port; 52 | 53 | } 54 | 55 | /** 56 | * Starts the module, by creating a TCP socket to the server. 57 | */ 58 | public void start() throws IOException, MqttException { 59 | final String methodName = "start"; 60 | try { 61 | // InetAddress localAddr = InetAddress.getLocalHost(); 62 | // socket = factory.createSocket(host, port, localAddr, 0); 63 | // @TRACE 252=connect to host {0} port {1} timeout {2} 64 | log.fine(className,methodName, "252", new Object[] {host, new Integer(port), new Long(conTimeout*1000)}); 65 | SocketAddress sockaddr = new InetSocketAddress(host, port); 66 | socket = factory.createSocket(); 67 | socket.connect(sockaddr, conTimeout*1000); 68 | 69 | // SetTcpNoDelay was originally set ot true disabling Nagle's algorithm. 70 | // This should not be required. 71 | // socket.setTcpNoDelay(true); // TCP_NODELAY on, which means we do not use Nagle's algorithm 72 | } 73 | catch (ConnectException ex) { 74 | //@TRACE 250=Failed to create TCP socket 75 | log.fine(className,methodName,"250",null,ex); 76 | throw new MqttException(MqttException.REASON_CODE_SERVER_CONNECT_ERROR, ex); 77 | } 78 | } 79 | 80 | public InputStream getInputStream() throws IOException { 81 | return socket.getInputStream(); 82 | } 83 | 84 | public OutputStream getOutputStream() throws IOException { 85 | return socket.getOutputStream(); 86 | } 87 | 88 | /** 89 | * Stops the module, by closing the TCP socket. 90 | */ 91 | public void stop() throws IOException { 92 | if (socket != null) { 93 | try { 94 | socket.close(); 95 | } catch(AssertionError e){ 96 | } 97 | } 98 | 99 | } 100 | 101 | /** 102 | * Set the maximum time to wait for a socket to be established 103 | * @param timeout 104 | */ 105 | public void setConnectTimeout(int timeout) { 106 | this.conTimeout = timeout; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/logcat.properties: -------------------------------------------------------------------------------- 1 | # @start_prolog@ 2 | # ============================================================================ 3 | # 4 | # 5724-H72 5 | # 6 | # (C) Copyright IBM Corp. 2010, 2010 7 | # 8 | # The source code for the program is not published 9 | # or otherwise divested of its trade secrets. 10 | # irrespective of what has been deposited with the U.S.Copyright Office. 11 | # 12 | # ============================================================================ 13 | # @end_prolog@ 14 | # ------------------------------------------------------------------------------------------------- 15 | # NLS_MESSAGEFORMAT_VAR 16 | # NLS_ENCODING=UNICODE 17 | # ------------------------------------------------------------------------------------------------- 18 | 0=MQTT Catalog 19 | 200=internalSend key={0} message={1} token={2} 20 | 213=fail: token in use: key={0} message={1} token={2} 21 | 208=failed: not connected 22 | 224=failed: not disconnected 23 | 214=state=CONNECTING 24 | 207=connect failed: not disconnected {0} 25 | 215=state=CONNECTED 26 | 204=connect failed: rc={0} 27 | 216=state=DISCONNECTING 28 | 217=state=DISCONNECTED 29 | 222=> 30 | 211=failed: already disconnected 31 | 219=failed: already disconnecting 32 | 210=failed: called on callback thread 33 | 223=failed: in closed state 34 | 218=state=DISCONNECTING 35 | 220=> 36 | 212=connect failed: unexpected exception 37 | 209=connect failed: unexpected exception 38 | 221=> 39 | 603=clearState 40 | 602=key={0} exception 41 | 601=key={0} message={1} 42 | 600=> 43 | 604=inbound QoS 2 publish key={0} message={1} 44 | 605=outbound QoS 2 pubrel key={0} message={1} 45 | 606=outbound QoS 2 completed key={0} message={1} 46 | 607=outbound QoS 2 publish key={0} message={1} 47 | 608=outbound QoS 1 publish key={0} message={1} 48 | 609=removing orphaned pubrel key={0} 49 | 610=QoS 2 publish key={0} 50 | 611=QoS 2 pubrel key={0} 51 | 612=QoS 1 publish key={0} 52 | 613= sending {0} msgs at max inflight window 53 | 628=pending publish key={0} qos={1} message={2} 54 | 615=pending send key={0} message {1} 55 | 618=key={0} QoS={1} 56 | 619=Timed out as no activity, keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 57 | 620=ping needed. keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 58 | 644=nothing to send, wait on queueLock 59 | 621=no outstanding flows and not connected 60 | 617=+1 inflightpubrels={0} 61 | 622=inflight window full wait on queueLock for space 62 | 647=not connected 63 | 623=+1 actualInFlight={0} 64 | 625=key={0} 65 | 646=-1 actualInFlight={0} 66 | 626=quiescing={0} actualInFlight={1} pendingFlows={2} inFlightPubRels={3} callbackQuiesce={4} tokens={5} 67 | 627=received key={0} message={1} 68 | 651=received key={0} message={1} 69 | 629=received key={0} token={1} message={2} 70 | 650=removed Qos 1 publish. key={0} 71 | 645=removed QoS 2 publish/pubrel. key={0}, -1 inFlightPubRels={1} 72 | 648=key{0}, msg={1}, excep={2} 73 | 649=key={0},excep={1} 74 | 631=connected 75 | 632=reason {0} 76 | 633=disconnected 77 | 637=timeout={0} 78 | 639=wait for outstanding: actualInFlight={0} pendingFlows={1} inFlightPubRels={2} tokens={3} 79 | 640=finished 80 | 638=notifying queueLock holders 81 | 641=remove publish from persistence. key={0} 82 | 700=stopping 83 | 701=notify workAvailable and wait for run 84 | 703=stopped 85 | 704=wait for workAvailable 86 | 706=notify spaceAvailable 87 | 714=callback threw exception 88 | 705=callback and notify for key={0} 89 | 708=call connectionLost 90 | 720=exception from connectionLost {0} 91 | 716=call onSuccess key={0} 92 | 717=call onFailure key {0} 93 | 709=wait for spaceAvailable 94 | 710=new msg avail, notify workAvailable 95 | 711=quiesce notify spaceAvailable 96 | 713=call messageArrived key={0} topic={1} 97 | 715=new workAvailable. key={0} 98 | 719=callback threw ex: 99 | 855=starting 100 | 850=stopping 101 | 851=stopped 102 | 852=network read message 103 | 856=Stopping, MQttException 104 | 853=Stopping due to IOException 105 | 854=< 106 | 800=stopping sender 107 | 801=stopped 108 | 802=network send key={0} msg={1} 109 | 803=get message returned null, stopping} 110 | 805=< 111 | 804=key={0} exception 112 | 308=<> 113 | 306=key={0} 114 | 302=existing key={0} message={1} token={2} 115 | 303=creating new token key={0} message={1} token={2} 116 | 300=key={0} message={1} 117 | 307=key={0} token={1} 118 | 309=resp={0} 119 | 310=> 120 | 311=> 121 | 312=> 122 | 305=> {0} tokens 123 | 260=setEnabledCiphers ciphers={0} 124 | 252=connect to host {0} port {1} timeout {2} 125 | 250=Failed to create TCP socket 126 | 407=key={0} wait max={1} token={2} 127 | 406=key={0} timed out token={1} 128 | 400=>key={0} timeout={1} sent={2} completed={3} hasException={4} response={5} token={6} 129 | 408=key={0} wait max={1} 130 | 401=failed with exception 131 | 402=key={0} response={1} 132 | 404=>key={0} response={1} excep={2} 133 | 411=>key={0} response={1} excep={2} 134 | 409=wait key={0} 135 | 403=> key={0} 136 | 410=> key={0} 137 | 101= ClientID={0} ServerURI={1} PersistenceType={2} 138 | 115=URI={0} 139 | 103=cleanSession={0} connectionTimeout={1} TimekeepAlive={2} userName={3} password={4} will={5} userContext={6} callback={7} 140 | 104=> quiesceTimeout={0} userContext={1} callback={2} 141 | 105=< exception 142 | 108=< 143 | 106=Subscribe topic={0} userContext={1} callback={2} 144 | 109=< 145 | 107=Unsubscribe topic={0} userContext={1} callback={2} 146 | 110=< 147 | 111=< topic={0} message={1}userContext={1} callback={2} 148 | 112=< 149 | 113=< 150 | 114=> 151 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/logcat_es.properties: -------------------------------------------------------------------------------- 1 | # @start_prolog@ 2 | # ============================================================================ 3 | # 4 | # 5724-H72 5 | # 6 | # (C) Copyright IBM Corp. 2010, 2010 7 | # 8 | # The source code for the program is not published 9 | # or otherwise divested of its trade secrets. 10 | # irrespective of what has been deposited with the U.S.Copyright Office. 11 | # 12 | # ============================================================================ 13 | # @end_prolog@ 14 | # ------------------------------------------------------------------------------------------------- 15 | # NLS_MESSAGEFORMAT_VAR 16 | # NLS_ENCODING=UNICODE 17 | # ------------------------------------------------------------------------------------------------- 18 | 0=Cat\u00e1logo de MQTT 19 | 200=clave internalSend={0} mensaje={1} se\u00f1al={2} 20 | 213=anomal\u00eda: se\u00f1al utilizada: clave={0} mensaje={1} se\u00f1al={2} 21 | 208=anomal\u00eda: no conectado 22 | 224=anomal\u00eda: no desconectado 23 | 214=estado=CONECTANDO 24 | 207=la conexi\u00f3n ha fallado: no desconectado {0} 25 | 215=estado=CONECTADO 26 | 204=la conexi\u00f3n ha fallado: rc={0} 27 | 216=estado=DESCONECTANDO 28 | 217=estado=DESCONECTADO 29 | 222=> 30 | 211=anomal\u00eda: ya desconectado 31 | 219=anomal\u00eda: ya desconectando 32 | 210=anomal\u00eda: llamada en hebra de devoluci\u00f3n de llamada 33 | 223=anomal\u00eda: en estado cerrado 34 | 218=estado=DESCONECTANDO 35 | 220=> 36 | 212=la conexi\u00f3n ha fallado: excepci\u00f3n inesperada 37 | 209=la conexi\u00f3n ha fallado: excepci\u00f3n inesperada 38 | 221=> 39 | 603=clearState 40 | 602=excepci\u00f3n de clave={0} 41 | 601=clave={0} mensaje={1} 42 | 600=> 43 | 604=clave de publicaci\u00f3n QoS 2 de entrada={0} mensaje={1} 44 | 605=clave pubrel QoS 2 de salida={0} mensaje={1} 45 | 606=clave de finalizaci\u00f3n QoS 2 de salida={0} mensaje={1} 46 | 607=clave de publicaci\u00f3n QoS 2 de salida={0} mensaje={1} 47 | 608=clave de publicaci\u00f3n QoS 1 de salida={0} mensaje={1} 48 | 609=eliminando clave pubrel hu\u00e9rfana={0} 49 | 610=clave de publicaci\u00f3n QoS 2={0} 50 | 611=clave pubrel QoS 2={0} 51 | 612=clave de publicaci\u00f3n QoS 1={0} 52 | 613= enviando {0} msgs en ventana de m\u00e1ximo en curso 53 | 628=clave de publicaci\u00f3n pendiente={0} qos={1} mensaje={2} 54 | 615=clave de env\u00edo pendiente={0} mensaje {1} 55 | 618=clave={0} QoS={1} 56 | 619=Tiempo de espera agotado debido a inactividad, keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 57 | 620=ping necesario. keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 58 | 644=nada que enviar, en espera en queueLock 59 | 621=no hay flujos pendientes y no est\u00e1 conectado 60 | 617=+1 inflightpubrels={0} 61 | 622=espera completa de ventana en curso en queueLock para espacio 62 | 647=no conectado 63 | 623=+1 actualInFlight={0} 64 | 625=clave={0} 65 | 646=-1 actualInFlight={0} 66 | 626=quiescing={0} actualInFlight={1} pendingFlows={2} inFlightPubRels={3} callbackQuiesce={4} tokens={5} 67 | 627=clave recibida={0} mensaje={1} 68 | 651=clave recibida={0} mensaje={1} 69 | 629=clave recibida={0} se\u00f1al={1} mensaje={2} 70 | 650=publicaci\u00f3n Qos 1 eliminada. clave={0} 71 | 645=publicaci\u00f3n/pubrel QoS 2 eliminada. clave={0}, -1 inFlightPubRels={1} 72 | 648=clave{0}, msg={1}, excep={2} 73 | 649=clave={0},excep={1} 74 | 631=conectado 75 | 632=raz\u00f3n {0} 76 | 633=desconectado 77 | 637=tiempo de espera={0} 78 | 639=en espera de pendientes: actualInFlight={0} pendingFlows={1} inFlightPubRels={2} tokens={3} 79 | 640=finalizado 80 | 638=notificando poseedores de queueLock 81 | 641=eliminar publicaci\u00f3n de persistencia. clave={0} 82 | 700=deteniendo 83 | 701=notificar workAvailable y esperar ejecuci\u00f3n 84 | 703=detenido 85 | 704=en espera de workAvailable 86 | 706=notificar spaceAvailable 87 | 714=devoluci\u00f3n de llamada ha generado una excepci\u00f3n 88 | 705=devoluci\u00f3n de llamada y notificaci\u00f3n para clave={0} 89 | 708=llamada a connectionLost 90 | 720=excepci\u00f3n de connectionLost {0} 91 | 716=llamada onSuccess clave={0} 92 | 717=llamada onFailure clave {0} 93 | 709=en espera de spaceAvailable 94 | 710=nuevo msg disponible, notificar workAvailable 95 | 711=desactivar notificaci\u00f3n spaceAvailable 96 | 713=llamada messageArrived clave={0} tema={1} 97 | 715=nuevo workAvailable. clave={0} 98 | 719=devoluci\u00f3n de llamada ha lanzado la ex: 99 | 855=iniciando 100 | 850=deteniendo 101 | 851=detenido 102 | 852=mensaje de lectura de red 103 | 856=Deteniendo, MQttException 104 | 853=Deteniendo debido a Excepci\u00f3n de E/S 105 | 854=< 106 | 800=deteniendo emisor 107 | 801=detenido 108 | 802=clave de env\u00edo de red={0} msg={1} 109 | 803=get message ha devuelto null, deteniendo} 110 | 805=< 111 | 804=excepci\u00f3n de clave={0} 112 | 308=<> 113 | 306=clave={0} 114 | 302=clave existente={0} mensaje={1} se\u00f1al={2} 115 | 303=creando nueva clave de se\u00f1al={0} mensaje={1} se\u00f1al={2} 116 | 300=clave={0} mensaje={1} 117 | 307=clave={0} se\u00f1al={1} 118 | 309=resp={0} 119 | 310=> 120 | 311=> 121 | 312=> 122 | 305=> {0} se\u00f1ales 123 | 260=setEnabledCiphers ciphers={0} 124 | 252=conectar a host {0} puerto {1} tiempo de espera {2} 125 | 250=No se ha podido crear el socket TCP 126 | 407=clave={0} espera m\u00e1x={1} se\u00f1al={2} 127 | 406=clave={0} se\u00f1al con tiempo de espera agotado={1} 128 | 400=>clave={0} tiempo de espera={1} enviados={2} completados={3} hasException={4} respuesta={5} se\u00f1al={6} 129 | 408=clave={0} espera m\u00e1x={1} 130 | 401=anomal\u00eda con excepci\u00f3n 131 | 402=clave={0} respuesta={1} 132 | 404=>clave={0} respuesta={1} excep={2} 133 | 411=>clave={0} respuesta={1} excep={2} 134 | 409=clave de espera={0} 135 | 403=> clave={0} 136 | 410=> clave={0} 137 | 101= ClientID={0} ServerURI={1} PersistenceType={2} 138 | 115=URI={0} 139 | 103=cleanSession={0} connectionTimeout={1} TimekeepAlive={2} userName={3} password={4} will={5} userContext={6} callback={7} 140 | 104=> quiesceTimeout={0} userContext={1} callback={2} 141 | 105=< excepci\u00f3n 142 | 108=< 143 | 106=Suscribir tema={0} userContext={1} callback={2} 144 | 109=< 145 | 107=Anular suscripci\u00f3n de tema={0} userContext={1} callback={2} 146 | 110=< 147 | 111=< topic={0} message={1}userContext={1} callback={2} 148 | 112=< 149 | 113=< 150 | 114=> 151 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/logcat_fr.properties: -------------------------------------------------------------------------------- 1 | # @start_prolog@ 2 | # ============================================================================ 3 | # 4 | # 5724-H72 5 | # 6 | # (C) Copyright IBM Corp. 2010, 2010 7 | # 8 | # The source code for the program is not published 9 | # or otherwise divested of its trade secrets. 10 | # irrespective of what has been deposited with the U.S.Copyright Office. 11 | # 12 | # ============================================================================ 13 | # @end_prolog@ 14 | # ------------------------------------------------------------------------------------------------- 15 | # NLS_MESSAGEFORMAT_VAR 16 | # NLS_ENCODING=UNICODE 17 | # ------------------------------------------------------------------------------------------------- 18 | 0=Catalogue MQTT 19 | 200=internalSend cl\u00e9={0} message={1} jeton={2} 20 | 213=\u00e9chec: jeton en cours d''utilisation: cl\u00e9={0} message={1} jeton={2} 21 | 208=\u00e9chou\u00e9: non connect\u00e9 22 | 224=\u00e9chou\u00e9: non d\u00e9connect\u00e9 23 | 214=\u00e9tat=CONNEXION 24 | 207=connexion \u00e9chou\u00e9e: non d\u00e9connect\u00e9 {0} 25 | 215=\u00e9tat=CONNECTE 26 | 204=connexion \u00e9chou\u00e9e: rc={0} 27 | 216=\u00e9tat=DECONNEXION 28 | 217=\u00e9tat=DECONNECTE 29 | 222=> 30 | 211=\u00e9chou\u00e9: d\u00e9j\u00e0 d\u00e9connect\u00e9 31 | 219=\u00e9chou\u00e9: d\u00e9j\u00e0 en cours de d\u00e9connexion 32 | 210=\u00e9chou\u00e9: appel\u00e9 sur unit\u00e9 d'ex\u00e9cution de rappel 33 | 223=\u00e9chou\u00e9: \u00e9tat ferm\u00e9 34 | 218=\u00e9tat=DECONNEXION 35 | 220=> 36 | 212=connexion \u00e9chou\u00e9e: exception inattendue 37 | 209=connexion \u00e9chou\u00e9e: exception inattendue 38 | 221=> 39 | 603=clearState 40 | 602=cl\u00e9={0} exception 41 | 601=cl\u00e9={0} message={1} 42 | 600=> 43 | 604=QoS 2 entrante cl\u00e9 de publication={0} message={1} 44 | 605=QoS 2 sortante cl\u00e9 pubrel={0} message={1} 45 | 606=QoS 2 sortante cl\u00e9 termin\u00e9e={0} message={1} 46 | 607=QoS 2 sortante cl\u00e9 de publication={0} message={1} 47 | 608=QoS 1 sortante cl\u00e9 de publication={0} message={1} 48 | 609=suppression de cl\u00e9 pubrel orpheline={0} 49 | 610=QoS 2 cl\u00e9 de publication={0} 50 | 611=QoS 2 cl\u00e9 pubrel={0} 51 | 612=QoS 1 cl\u00e9 de publication={0} 52 | 613= envoi de {0} msgs \u00e0 la fen\u00eatre en cours max 53 | 628=cl\u00e9 de publication en attente={0} qos={1} message={2} 54 | 615=cl\u00e9 d''envoi en attente={0} message {1} 55 | 618=cl\u00e9={0} QoS={1} 56 | 619=D\u00e9lai d''attente d\u00e9pass\u00e9 car aucune activit\u00e9, keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 57 | 620=ping n\u00e9cessaire. keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 58 | 644=rien \u00e0 envoyer, attente sur queueLock 59 | 621=aucun flux en attente et non connect\u00e9 60 | 617=+1 inflightpubrels={0} 61 | 622=attente compl\u00e8te fen\u00eatre en cours sur queueLock pour de l'espace 62 | 647=non connect\u00e9 63 | 623=+1 actualInFlight={0} 64 | 625=cl\u00e9={0} 65 | 646=-1 actualInFlight={0} 66 | 626=mise au repos={0} actualInFlight={1} pendingFlows={2} inFlightPubRels={3} callbackQuiesce={4} jetons={5} 67 | 627=cl\u00e9 re\u00e7ue={0} message={1} 68 | 651=cl\u00e9 re\u00e7ue={0} message={1} 69 | 629=cl\u00e9 re\u00e7ue={0} jeton={1} message={2} 70 | 650=Qos 1 supprim\u00e9 cl\u00e9 de publication={0} 71 | 645=QoS 2 supprim\u00e9e cl\u00e9 de publication/pubrel={0}, -1 inFlightPubRels={1} 72 | 648=cl\u00e9{0}, msg={1}, excep={2} 73 | 649=cl\u00e9={0},excep={1} 74 | 631=connect\u00e9 75 | 632=motif {0} 76 | 633=d\u00e9connect\u00e9 77 | 637=d\u00e9lai d''attente={0} 78 | 639=attente de mise en attente: actualInFlight={0} pendingFlows={1} inFlightPubRels={2} jetons={3} 79 | 640=fini 80 | 638=notification des d\u00e9tenteurs queueLock 81 | 641=supprimer la publication de cl\u00e9 de persistance={0} 82 | 700=arr\u00eater 83 | 701=notifier workAvailable et attente d'ex\u00e9cution 84 | 703=arr\u00eat\u00e9 85 | 704=attente de workAvailable 86 | 706=notifier spaceAvailable 87 | 714=le rappel a \u00e9mis une exception 88 | 705=rappel et notification pour cl\u00e9={0} 89 | 708=appel connectionLost 90 | 720=exception de connectionLost {0} 91 | 716=appel cl\u00e9 onSuccess={0} 92 | 717=appel cl\u00e9 onFailure {0} 93 | 709=attente de spaceAvailable 94 | 710=nouveau msg dispo, notifier workAvailable 95 | 711=mise au repos notification spaceAvailable 96 | 713=appel messageArrived cl\u00e9={0} rubrique={1} 97 | 715=nouveau workAvailable. cl\u00e9={0} 98 | 719=le rappel a \u00e9mis ex: 99 | 855=d\u00e9marrage 100 | 850=arr\u00eater 101 | 851=arr\u00eat\u00e9 102 | 852=message lecture r\u00e9seau 103 | 856=arr\u00eat, MQttException 104 | 853=Arr\u00eat d\u00fb \u00e0 IOException 105 | 854=< 106 | 800=arr\u00eat \u00e9metteur 107 | 801=arr\u00eat\u00e9 108 | 802=cl\u00e9 d''envoi r\u00e9seau={0} msg={1} 109 | 803=message get a renvoy\u00e9 null, arr\u00eat} 110 | 805=< 111 | 804=cl\u00e9={0} exception 112 | 308=<> 113 | 306=cl\u00e9={0} 114 | 302=cl\u00e9 existante={0} message={1} jeton={2} 115 | 303=cr\u00e9ation nouveau jeton cl\u00e9={0} message={1} jeton={2} 116 | 300=cl\u00e9={0} message={1} 117 | 307=cl\u00e9={0} jeton={1} 118 | 309=resp={0} 119 | 310=> 120 | 311=> 121 | 312=> 122 | 305=> {0} jetons 123 | 260=chiffrements setEnabledCiphers={0} 124 | 252=connexion \u00e0 l''h\u00f4te {0} port {1} d\u00e9lai d''attente {2} 125 | 250=Echec de cr\u00e9ation socket TCP 126 | 407=cl\u00e9={0} attente max={1} jeton={2} 127 | 406=cl\u00e9={0} jeton expir\u00e9={1} 128 | 400=>cl\u00e9={0} d\u00e9lai d''attente={1} envoy\u00e9={2} termin\u00e9={3} hasException={4} r\u00e9ponse={5} jeton={6} 129 | 408=cl\u00e9={0} attente max={1} 130 | 401=\u00e9chec avec exception 131 | 402=cl\u00e9={0} r\u00e9ponse={1} 132 | 404=>cl\u00e9={0} r\u00e9ponse={1} excep={2} 133 | 411=>cl\u00e9={0} r\u00e9ponse={1} excep={2} 134 | 409=attente cl\u00e9={0} 135 | 403=> cl\u00e9={0} 136 | 410=> cl\u00e9={0} 137 | 101= ClientID={0} ServerURI={1} PersistenceType={2} 138 | 115=URI={0} 139 | 103=cleanSession={0} connectionTimeout={1} TimekeepAlive={2} userName={3} password={4} will={5} userContext={6} callback={7} 140 | 104=> quiesceTimeout={0} userContext={1} callback={2} 141 | 105=< exception 142 | 108=< 143 | 106=Rubrique d''abonnement={0} userContext={1} callback={2} 144 | 109=< 145 | 107=Rubrique de d\u00e9sabonnement={0} userContext={1} callback={2} 146 | 110=< 147 | 111=< rubrique={0} message={1}userContext={1} callback={2} 148 | 112=< 149 | 113=< 150 | 114=> 151 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/logcat_it.properties: -------------------------------------------------------------------------------- 1 | # @start_prolog@ 2 | # ============================================================================ 3 | # 4 | # 5724-H72 5 | # 6 | # (C) Copyright IBM Corp. 2010, 2010 7 | # 8 | # The source code for the program is not published 9 | # or otherwise divested of its trade secrets. 10 | # irrespective of what has been deposited with the U.S.Copyright Office. 11 | # 12 | # ============================================================================ 13 | # @end_prolog@ 14 | # ------------------------------------------------------------------------------------------------- 15 | # NLS_MESSAGEFORMAT_VAR 16 | # NLS_ENCODING=UNICODE 17 | # ------------------------------------------------------------------------------------------------- 18 | 0=Catalogo MQTT 19 | 200=chiave internalSend={0} messaggio={1} token={2} 20 | 213=errore: token in uso: chiave={0} messaggio={1} token={2} 21 | 208=operazione non riuscita: non connesso 22 | 224=operazione non riuscita: non disconnesso 23 | 214=stato=CONNESSIONE IN CORSO 24 | 207=connessione non riuscita: {0} non disconnesso 25 | 215=stato=CONNESSO 26 | 204=connessione non riuscita: codice di ritorno={0} 27 | 216=stato=DISCONNESSIONE IN CORSO 28 | 217=stato=DISCONNESSO 29 | 222=> 30 | 211=operazione non riuscita: gi\u00e0 disconnesso 31 | 219=operazione non riuscita: gi\u00e0 in fase di disconnessione 32 | 210=operazione non riuscita: richiamato su thread di callback 33 | 223=operazione non riuscita: in stato Chiuso 34 | 218=stato=DISCONNESSIONE IN CORSO 35 | 220=> 36 | 212=connessione non riuscita: eccezione imprevista 37 | 209=connessione non riuscita: eccezione imprevista 38 | 221=> 39 | 603=clearState 40 | 602=chiave={0} eccezione 41 | 601=chiave={0} messaggio={1} 42 | 600=> 43 | 604=chiave pubblicazione QoS 2 in entrata={0} messaggio={1} 44 | 605=chiave pubrel QoS 2 in uscita={0} messaggio={1} 45 | 606=chiave completata QoS 2 in uscita={0} messaggio={1} 46 | 607=chiave pubblicazione QoS 2 in uscita={0} messaggio={1} 47 | 608=chiave pubblicazione QoS 1 in uscita={0} messaggio={1} 48 | 609=rimozione chiave pubrel orfana={0} 49 | 610=chiave pubblicazione QoS 2={0} 50 | 611=chiave pubrel QoS 2={0} 51 | 612=chiave pubblicazione QoS 1={0} 52 | 613= invio di {0} messaggi alla finestra in fase di elaborazione massima 53 | 628=chiave pubblicazione in sospeso={0} qos={1} messaggio={2} 54 | 615=chiave invio in sospeso={0} messaggio {1} 55 | 618=chiave={0} QoS={1} 56 | 619=Time out per mancanza di attivit\u00e0, keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 57 | 620=ping necessario. keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 58 | 644=niente da inviare, attesa su queueLock 59 | 621=nessun flusso in sospeso e nessuna connessione 60 | 617=+1 inflightpubrels={0} 61 | 622=finestra in fase di elaborazione in attesa su queueLock per spazio 62 | 647=non connesso 63 | 623=+1 actualInFlight={0} 64 | 625=chiave={0} 65 | 646=-1 actualInFlight={0} 66 | 626=inattivit\u00e0={0} actualInFlight={1} pendingFlows={2} inFlightPubRels={3} callbackQuiesce={4} token={5} 67 | 627=chiave ricevuta={0} messaggio={1} 68 | 651=chiave ricevuta={0} messaggio={1} 69 | 629=chiave ricevuta={0} token={1} messaggio={2} 70 | 650=pubblicazione Qos 1 rimossa. chiave={0} 71 | 645=pubblicazione/pubrel QoS 2 rimossa. chiave={0}, -1 inFlightPubRels={1} 72 | 648=chiave{0}, messaggio={1}, eccezione={2} 73 | 649=chiave={0},eccezione={1} 74 | 631=connesso 75 | 632=motivo {0} 76 | 633=disconnesso 77 | 637=timeout={0} 78 | 639=in attesa di sospensione: actualInFlight={0} pendingFlows={1} inFlightPubRels={2} token={3} 79 | 640=terminato 80 | 638=notifica contenitori queueLock 81 | 641=rimuovi pubblicazione da persistenza. chiave={0} 82 | 700=arresto 83 | 701=notifica workAvailable e attendi esecuzione 84 | 703=arrestato 85 | 704=attendi workAvailable 86 | 706=notifica spaceAvailable 87 | 714=callback ha generato un'eccezione 88 | 705=callback e notifica per la chiave={0} 89 | 708=chiama connectionLost 90 | 720=eccezione da connectionLost {0} 91 | 716=chiama chiave onSuccess={0} 92 | 717=chiama chiave onFailure {0} 93 | 709=attendi spaceAvailable 94 | 710=nuovo mess. disponibile, notifica workAvailable 95 | 711=sospendi notifica spaceAvailable 96 | 713=chiama chiave messageArrived={0} argomento={1} 97 | 715=nuovo workAvailable. chiave={0} 98 | 719=callback ha generato un'eccezione: 99 | 855=avvio 100 | 850=arresto 101 | 851=arrestato 102 | 852=messaggio di lettura rete 103 | 856=Arresto, MQttException 104 | 853=Arresto a causa di IOException 105 | 854=< 106 | 800=arresto mittente 107 | 801=arrestato 108 | 802=chiave invio rete={0} messaggio={1} 109 | 803=ottieni messaggio che restituisce null, arresto} 110 | 805=< 111 | 804=chiave={0} eccezione 112 | 308=<> 113 | 306=chiave={0} 114 | 302=chiave esistente={0} messaggio={1} token={2} 115 | 303=creazione nuova chiave token={0} messaggio={1} token={2} 116 | 300=chiave={0} messaggio={1} 117 | 307=chiave={0} token={1} 118 | 309=risp={0} 119 | 310=> 120 | 311=> 121 | 312=> 122 | 305=> {0} token 123 | 260=cifre setEnabledCiphers={0} 124 | 252=connetti a host {0} porta {1} timeout {2} 125 | 250=Impossibile creare il socket TCP 126 | 407=chiave={0} attesa massima={1} token={2} 127 | 406=chiave={0} token in time out={1} 128 | 400=>chiave={0} timeout={1} inviato={2} completato={3} hasException={4} risposta={5} token={6} 129 | 408=chiave={0} attesa massima={1} 130 | 401=non riuscito con eccezione 131 | 402=chiave={0} risposta={1} 132 | 404=>chiave={0} risposta={1} eccezione={2} 133 | 411=>chiave={0} risposta={1} eccezione={2} 134 | 409=chiave attesa={0} 135 | 403=> chiave={0} 136 | 410=> chiave={0} 137 | 101= ClientID={0} ServerURI={1} PersistenceType={2} 138 | 115=URI={0} 139 | 103=cleanSession={0} connectionTimeout={1} TimekeepAlive={2} userName={3} password={4} will={5} userContext={6} callback={7} 140 | 104=> quiesceTimeout={0} userContext={1} callback={2} 141 | 105=< eccezione 142 | 108=< 143 | 106=Sottoscrivi argomento={0} userContext={1} callback={2} 144 | 109=< 145 | 107=Annulla sottoscrizione argomento={0} userContext={1} callback={2} 146 | 110=< 147 | 111=< argomento={0} messaggio={1}userContext={1} callback={2} 148 | 112=< 149 | 113=< 150 | 114=> 151 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/logcat_pt_BR.properties: -------------------------------------------------------------------------------- 1 | # @start_prolog@ 2 | # ============================================================================ 3 | # 4 | # 5724-H72 5 | # 6 | # (C) Copyright IBM Corp. 2010, 2010 7 | # 8 | # The source code for the program is not published 9 | # or otherwise divested of its trade secrets. 10 | # irrespective of what has been deposited with the U.S.Copyright Office. 11 | # 12 | # ============================================================================ 13 | # @end_prolog@ 14 | # ------------------------------------------------------------------------------------------------- 15 | # NLS_MESSAGEFORMAT_VAR 16 | # NLS_ENCODING=UNICODE 17 | # ------------------------------------------------------------------------------------------------- 18 | 0=Cat\u00e1logo MQTT 19 | 200=internalSend chave={0} mensagem={1} token={2} 20 | 213=falha: token em uso: chave={0} mensagem={1} token={2} 21 | 208=com falha: n\u00e3o conectado 22 | 224=com falha: n\u00e3o desconectado 23 | 214=estado=CONNECTING 24 | 207=conex\u00e3o com falha: n\u00e3o desconectado {0} 25 | 215=estado=CONNECTED 26 | 204=conex\u00e3o com falha: rc={0} 27 | 216=estado=DISCONNECTING 28 | 217=estado=DISCONNECTED 29 | 222=> 30 | 211=com falha: j\u00e1 desconectado 31 | 219=com falha: j\u00e1 desconectando 32 | 210=com falha: chamado no encadeamento de retorno de chamada 33 | 223=com falha: em estado encerrado 34 | 218=estado=DISCONNECTING 35 | 220=> 36 | 212=conex\u00e3o com falha: exce\u00e7\u00e3o inesperada 37 | 209=conex\u00e3o com falha: exce\u00e7\u00e3o inesperada 38 | 221=> 39 | 603=clearState 40 | 602=chave={0} exce\u00e7\u00e3o 41 | 601=chave={0} mensagem={1} 42 | 600=> 43 | 604=entrada QoS 2 chave de publica\u00e7\u00e3o={0} mensagem={1} 44 | 605=sa\u00edda QoS 2 chave pubrel={0} mensagem={1} 45 | 606=chave conclu\u00edda para QoS 2 de sa\u00edda={0} mensagem={1} 46 | 607=chave de publica\u00e7\u00e3o de QoS 2 de sa\u00edda={0} mensagem={1} 47 | 608=chave de publica\u00e7\u00e3o de QoS 1 de sa\u00edda={0} mensagem={1} 48 | 609=removendo chave pubrel \u00f3rf\u00e3={0} 49 | 610=chave de publica\u00e7\u00e3o QoS 2={0} 50 | 611=chave pubrel QoS 2={0} 51 | 612=chave de publica\u00e7\u00e3o QoS 1={0} 52 | 613= enviando {0} msgs no m\u00e1x. de janela em andamento 53 | 628=chave de publica\u00e7\u00e3o pendente={0} qos={1} mensagem={2} 54 | 615=chave de envio pendente={0} mensagem {1} 55 | 618=chave={0} QoS={1} 56 | 619=Tempo limite atingido devido \u00e0 falta de atividade, keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 57 | 620=ping necess\u00e1rio. keepAlive={0} lastOutboundActivity={1} lastInboundActivity={2} 58 | 644=nada a enviar, espere em queueLock 59 | 621=sem fluxos pendentes e n\u00e3o conectado 60 | 617=+1 inflightpubrels={0} 61 | 622=Janela em andamento cheia espere em queueLock para espa\u00e7o 62 | 647=n\u00e3o conectado 63 | 623=+1 actualInFlight={0} 64 | 625=chave={0} 65 | 646=-1 actualInFlight={0} 66 | 626=quiescing={0} actualInFlight={1} pendingFlows={2} inFlightPubRels={3} callbackQuiesce={4} tokens={5} 67 | 627=chave de recebimento={0} mensagem={1} 68 | 651=chave de recebimento={0} mensagem={1} 69 | 629=chave de recebimento={0} token={1} mensagem={2} 70 | 650=publica\u00e7\u00e3o Qos 1 removida. chave={0} 71 | 645=publica\u00e7\u00e3o/pubrel QoS 2 removida. chave={0}, -1 inFlightPubRels={1} 72 | 648=chave{0}, msg={1}, exce={2} 73 | 649=chave={0},exce={1} 74 | 631=conectado 75 | 632=motivo {0} 76 | 633=desconectado 77 | 637=tempo limite={0} 78 | 639=esperar por pend\u00eancia: actualInFlight={0} pendingFlows={1} inFlightPubRels={2} tokens={3} 79 | 640=conclu\u00eddo 80 | 638=notificando portadores do queueLock 81 | 641=remover publica\u00e7\u00e3o da persist\u00eancia. chave={0} 82 | 700=parando 83 | 701=notificar workAvailable e esperar pela execu\u00e7\u00e3o 84 | 703=parado 85 | 704=esperar por workAvailable 86 | 706=notificar spaceAvailable 87 | 714=retornar chamada de exce\u00e7\u00e3o lan\u00e7ada 88 | 705=retornar chamada e notificar para a chave={0} 89 | 708=chamar connectionLost 90 | 720=exce\u00e7\u00e3o do connectionLost {0} 91 | 716=chamar chave onSuccess={0} 92 | 717=chamar chave onFailure {0} 93 | 709=esperar por spaceAvailable 94 | 710=nova msg dispon\u00edvel, notificar workAvailable 95 | 711=modo quiesce notificar spaceAvailable 96 | 713=chamar chave messageArrived={0} t\u00f3pico={1} 97 | 715=nova workAvailable. chave={0} 98 | 719=retornar chamado de lance ex: 99 | 855=iniciando 100 | 850=parando 101 | 851=parado 102 | 852=mensagem de leitura de rede 103 | 856=Parando, MQttException 104 | 853=parando devido ao IOException 105 | 854=< 106 | 800=parando emissor 107 | 801=parado 108 | 802=chave de envio de rede={0} msg={1} 109 | 803=obter retorno de mensagem NULL, parando} 110 | 805=< 111 | 804=chave={0} exce\u00e7\u00e3o 112 | 308=<> 113 | 306=chave={0} 114 | 302=chave existente={0} mensagem={1} token={2} 115 | 303=criando nova chave de token={0} mensagem={1} token={2} 116 | 300=chave={0} mensagem={1} 117 | 307=chave={0} token={1} 118 | 309=resp={0} 119 | 310=> 120 | 311=> 121 | 312=> 122 | 305=> {0} tokens 123 | 260=setEnabledCiphers ciphers={0} 124 | 252=conectar com o host {0} porta {1} tempo limite {2} 125 | 250=Falha ao criar o soquete do TCP 126 | 407=chave={0} espera m\u00e1x.={1} token={2} 127 | 406=chave={0} tempo limite atingido token={1} 128 | 400=>chave={0} tempo limite={1} enviado={2} conclu\u00eddo={3} hasException={4} resposta={5} token={6} 129 | 408=chave={0} espera m\u00e1x.={1} 130 | 401=falhou com exce\u00e7\u00e3o 131 | 402=chave={0} resposta={1} 132 | 404=>chave={0} resposta={1} exce={2} 133 | 411=>chave={0} resposta={1} exce={2} 134 | 409=chave de espera={0} 135 | 403=> chave={0} 136 | 410=> chave={0} 137 | 101= ClientID={0} ServerURI={1} PersistenceType={2} 138 | 115=URI={0} 139 | 103=cleanSession={0} connectionTimeout={1} TimekeepAlive={2} userName={3} senha={4} testamento={5} userContext={6} retorno de chamada={7} 140 | 104=> quiesceTimeout={0} userContext={1} retorno de chamada={2} 141 | 105=< exce\u00e7\u00e3o 142 | 108=< 143 | 106=Assinar t\u00f3pico={0} userContext={1} retorno de chamada={2} 144 | 109=< 145 | 107=Cancelar assinatura de t\u00f3pico={0} userContext={1} retorno de chamada={2} 146 | 110=< 147 | 111=< t\u00f3pico={0} mensagem={1}userContext={1} retorno de chamada={2} 148 | 112=< 149 | 113=< 150 | 114=> 151 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=Invalid protocol version 15 | 2=Invalid client ID 16 | 3=Broker unavailable 17 | 4=Bad user name or password 18 | 5=Not authorized to connect 19 | 6=Unexpected error 20 | 32000=Timed out waiting for a response from the server 21 | 32100=Client is connected 22 | 32101=Client is disconnected 23 | 32102=Client is currently disconnecting 24 | 32103=Unable to connect to server 25 | 32104=Client is not connected 26 | 32105=The specified SocketFactory type does not match the broker URI 27 | 32106=SSL configuration error 28 | 32107=Disconnecting is not allowed from a callback method 29 | 32108=Unrecognized packet 30 | 32109=Connection lost 31 | 32110=Connect already in progress 32 | 32111=Client is closed 33 | 32200=Persistence already in use 34 | 32201=Token already in use 35 | 32202=Too many publishes in progress 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_cs.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=Neplatn\u00e1 verze protokolu 15 | 2=Neplatn\u00e9 ID klienta 16 | 3=Nedostupn\u00fd zprost\u0159edkovatel 17 | 4=Chybn\u00e9 jm\u00e9no u\u017eivatele nebo heslo 18 | 5=Chyb\u00ed autorizace pro p\u0159ipojen\u00ed 19 | 6=Neo\u010dek\u00e1van\u00e1 chyba 20 | 32000=Vypr\u0161en\u00ed \u010dasov\u00e9ho limitu pro odpov\u011b\u010f ze serveru 21 | 32100=Klient je p\u0159ipojen 22 | 32101=Klient je odpojen 23 | 32102=Klient se aktu\u00e1ln\u011b odpojuje 24 | 32103=Nelze se p\u0159ipojit k serveru 25 | 32104=Klient nen\u00ed p\u0159ipojen 26 | 32105=Ur\u010den\u00fd typ polo\u017eky SocketFactory neodpov\u00edd\u00e1 identifik\u00e1toru URI zprost\u0159edkovatele. 27 | 32106=Chyba konfigurace zabezpe\u010den\u00ed SSL 28 | 32107=Z metody zp\u011btn\u00e9ho vol\u00e1n\u00ed nen\u00ed povoleno odpojen\u00ed 29 | 32108=Nerozpoznan\u00fd paket 30 | 32109=P\u0159ipojen\u00ed bylo ztraceno. 31 | 32110=P\u0159ipojen\u00ed ji\u017e prob\u00edh\u00e1 32 | 32111=Klient je zav\u0159en 33 | 32200=Perzistence je ji\u017e pou\u017e\u00edv\u00e1na. 34 | 32201=Token se ji\u017e pou\u017e\u00edv\u00e1 35 | 32202=Prob\u00edh\u00e1 p\u0159\u00edli\u0161 mnoho publikov\u00e1n\u00ed 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_de.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=Protokollversion ung\u00fcltig 15 | 2=Client-ID ung\u00fcltig 16 | 3=Broker nicht verf\u00fcgbar 17 | 4=Benutzername oder Kennwort falsch 18 | 5=Keine Berechtigung f\u00fcr Verbindung 19 | 6=Unerwarteter Fehler 20 | 32000=Zeitlimit\u00fcberschreitung beim Warten auf eine Antwort vom Server 21 | 32100=Verbindung zu Client ist hergestellt 22 | 32101=Verbindung zu Client ist getrennt 23 | 32102=Verbindung zu Client wird derzeit getrennt 24 | 32103=Verbindung zu Server kann nicht hergestellt werden 25 | 32104=Keine Verbindung zu Client 26 | 32105=Der angegebene Socket-Factorytyp entspricht nicht der Broker-URI 27 | 32106=SSL-Konfigurationsfehler 28 | 32107=Trennung einer Verbindung \u00fcber eine Callback-Methode ist nicht zul\u00e4ssig 29 | 32108=Paket nicht erkannt 30 | 32109=Verbindung wurde getrennt 31 | 32110=Verbindungsherstellung wird ausgef\u00fchrt 32 | 32111=Client ist geschlossen 33 | 32200=Persistenz wird bereits verwendet 34 | 32201=Token wird bereits verwendet 35 | 32202=Zu viele Ver\u00f6ffentlichungen werden ausgef\u00fchrt 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_es.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=Versi\u00f3n de protocolo incorrecta 15 | 2=Identificador de cliente incorrecto 16 | 3=Intermediario no disponible 17 | 4=Nombre de usuario o contrase\u00f1a incorrecto 18 | 5=No autorizado a conectarse 19 | 6=Error inesperado 20 | 32000=Tiempo de espera excedido al esperar una respuesta del servidor 21 | 32100=El cliente est\u00e1 conectado 22 | 32101=El cliente est\u00e1 desconectado 23 | 32102=El cliente se est\u00e1 desconectando 24 | 32103=No es posible conectarse al servidor 25 | 32104=El cliente no est\u00e1 conectado 26 | 32105=El tipo SocketFactory especificado no coincide con el URI del intermediario 27 | 32106=Error de configuraci\u00f3n SSL 28 | 32107=No se permite la desconexi\u00f3n desde un m\u00e9todo de devoluci\u00f3n de llamada 29 | 32108=Paquete no reconocido 30 | 32109=Se ha perdido la conexi\u00f3n 31 | 32110=Conexi\u00f3n ya en curso 32 | 32111=El cliente est\u00e1 cerrado 33 | 32200=La persistencia ya se est\u00e1 utilizando 34 | 32201=La se\u00f1al ya se est\u00e1 utilizando 35 | 32202=Demasiadas publicaciones en curso 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_fr.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=Version de protocole incorrecte 15 | 2=ID client incorrect 16 | 3=Courtier indisponible 17 | 4=Nom d'utilisateur ou mot de passe incorrect 18 | 5=L'utilisateur n'est pas autoris\u00e9 \u00e0 se connecter 19 | 6=Erreur inattendue. 20 | 32000=Expiration du d\u00e9lai d'attente d'une r\u00e9ponse du serveur 21 | 32100=Client connect\u00e9 22 | 32101=Client d\u00e9connect\u00e9 23 | 32102=Client en cours de d\u00e9connexion 24 | 32103=Impossible de se connecter au serveur 25 | 32104=Client non connect\u00e9 26 | 32105=Le type SocketFactory sp\u00e9cifi\u00e9 ne correspond pas \u00e0 l'URI de courtier 27 | 32106=Erreur de configuration SSL 28 | 32107=D\u00e9connexion non autoris\u00e9e pour une m\u00e9thode de rappel 29 | 32108=Paquet non reconnu 30 | 32109=Connexion perdue 31 | 32110=Connexion d\u00e9j\u00e0 en cours 32 | 32111=Client ferm\u00e9 33 | 32200=La persistance est d\u00e9j\u00e0 en cours d'utilisation 34 | 32201=Jeton d\u00e9j\u00e0 en cours d'utilisation 35 | 32202=Trop de publications en cours 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_hu.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=\u00c9rv\u00e9nytelen protokoll v\u00e1ltozat 15 | 2=\u00c9rv\u00e9nytelen \u00fcgyf\u00e9lazonos\u00edt\u00f3 16 | 3=K\u00f6zvet\u00edt\u0151 nem el\u00e9rhet\u0151 17 | 4=Rossz felhaszn\u00e1l\u00f3i n\u00e9v vagy jelsz\u00f3 18 | 5=Nem jogosult csatlakozni 19 | 6=V\u00e1ratlan hiba 20 | 32000=T\u00fall\u00e9pte a megengedett id\u0151t a kiszolg\u00e1l\u00f3 v\u00e1lasz\u00e1ra v\u00e1rva 21 | 32100=Az \u00fcgyf\u00e9l csatlakoztatva van 22 | 32101=Az \u00fcgyf\u00e9l sz\u00e9tkapcsolt 23 | 32102=Az \u00fcgyf\u00e9l \u00e9pp megszak\u00edtja a kapcsolatot 24 | 32103=Nem lehet kapcsol\u00f3dni a kiszolg\u00e1l\u00f3hoz 25 | 32104=Az \u00fcgyf\u00e9l nincs csatlakoztatva 26 | 32105=A megadott SocketFactory t\u00edpus nem illeszkedik a k\u00f6zvet\u00edt\u0151 URI azonos\u00edt\u00f3hoz 27 | 32106=SSL konfigur\u00e1ci\u00f3s hiba 28 | 32107=A megszak\u00edt\u00e1s visszah\u00edv\u00e1s met\u00f3dusb\u00f3l nem enged\u00e9lyezett 29 | 32108=Ismeretlen csomag 30 | 32109=Kapcsolat elveszett 31 | 32110=A csatlakoz\u00e1s m\u00e1r folyamatban van 32 | 32111=Az \u00fcgyf\u00e9l bez\u00e1r\u00e1sra ker\u00fclt 33 | 32200=A megmarad\u00f3 \u00e1llapot m\u00e1r haszn\u00e1latban van 34 | 32201=A token m\u00e1r haszn\u00e1latban van. 35 | 32202=T\u00fal sok k\u00f6zz\u00e9t\u00e9tel van folyamatban 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_it.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=Versione di protocollo non valida 15 | 2=ID client non valido 16 | 3=Broker non disponibile 17 | 4=Nome utente o password non validi 18 | 5=Non autorizzato per la connessione 19 | 6=Errore imprevisto 20 | 32000=Scaduto in attesa di una risposta dal server 21 | 32100=Client connesso 22 | 32101=Client disconnesso 23 | 32102=Client in fase di disconnessione 24 | 32103=Impossibile effettuare la connessione al server 25 | 32104=Client non connesso 26 | 32105=Il tipo SocketFactory specificato non corrisponde all'URI del broker 27 | 32106=Errore di configurazione SSL 28 | 32107=Disconnessione non consentita da un metodo callback 29 | 32108=Pacchetto non riconosciuto 30 | 32109=Connessione persa 31 | 32110=Connessione gi\u00e0 in corso 32 | 32111=Client chiuso 33 | 32200=Persistenza gi\u00e0 in uso 34 | 32201=Token gi\u00e0 in uso 35 | 32202=Numero eccessivo di pubblicazioni in corso 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_ja.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=\u7121\u52b9\u306a\u30d7\u30ed\u30c8\u30b3\u30eb\u30fb\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059 15 | 2=\u7121\u52b9\u306a\u30af\u30e9\u30a4\u30a2\u30f3\u30c8 ID \u3067\u3059 16 | 3=\u30d6\u30ed\u30fc\u30ab\u30fc\u304c\u4f7f\u7528\u4e0d\u53ef\u3067\u3059 17 | 4=\u9593\u9055\u3063\u305f\u30e6\u30fc\u30b6\u30fc\u540d\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3067\u3059 18 | 5=\u63a5\u7d9a\u3059\u308b\u6a29\u9650\u304c\u3042\u308a\u307e\u305b\u3093 19 | 6=\u4e88\u671f\u3057\u306a\u3044\u30a8\u30e9\u30fc 20 | 32000=\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u306e\u5fdc\u7b54\u5f85\u6a5f\u304c\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306b\u306a\u308a\u307e\u3057\u305f 21 | 32100=\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u63a5\u7d9a\u3057\u307e\u3057\u305f 22 | 32101=\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u5207\u65ad\u3057\u307e\u3057\u305f 23 | 32102=\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f\u73fe\u5728\u5207\u65ad\u4e2d\u3067\u3059 24 | 32103=\u30b5\u30fc\u30d0\u30fc\u306b\u63a5\u7d9a\u3067\u304d\u307e\u305b\u3093 25 | 32104=\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f\u63a5\u7d9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093 26 | 32105=\u6307\u5b9a\u3055\u308c\u305f SocketFactory \u30bf\u30a4\u30d7\u306f\u30d6\u30ed\u30fc\u30ab\u30fc URI \u3068\u4e00\u81f4\u3057\u307e\u305b\u3093 27 | 32106=SSL \u69cb\u6210\u30a8\u30e9\u30fc\u3067\u3059 28 | 32107=\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u30fb\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u306e\u5207\u65ad\u306f\u8a31\u53ef\u3055\u308c\u307e\u305b\u3093 29 | 32108=\u8b58\u5225\u3055\u308c\u3066\u3044\u306a\u3044\u30d1\u30b1\u30c3\u30c8\u3067\u3059 30 | 32109=\u63a5\u7d9a\u55aa\u5931 31 | 32110=\u63a5\u7d9a\u51e6\u7406\u306f\u65e2\u306b\u9032\u884c\u4e2d\u3067\u3059 32 | 32111=\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304c\u30af\u30ed\u30fc\u30ba\u3055\u308c\u307e\u3057\u305f 33 | 32200=\u30d1\u30fc\u30b7\u30b9\u30bf\u30f3\u30b9\u306f\u3059\u3067\u306b\u4f7f\u7528\u4e2d\u3067\u3059\u3002 34 | 32201=\u30c8\u30fc\u30af\u30f3\u306f\u65e2\u306b\u4f7f\u7528\u4e2d\u3067\u3059 35 | 32202=\u51e6\u7406\u4e2d\u306e\u30d1\u30d6\u30ea\u30c3\u30b7\u30e5\u304c\u591a\u3059\u304e\u307e\u3059 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_ko.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=\uc62c\ubc14\ub974\uc9c0 \uc54a\uc740 \ud504\ub85c\ud1a0\ucf5c \ubc84\uc804 15 | 2=\uc62c\ubc14\ub974\uc9c0 \uc54a\uc740 \ud074\ub77c\uc774\uc5b8\ud2b8 ID 16 | 3=\ube0c\ub85c\ucee4 \uc0ac\uc6a9 \ubd88\uac00\ub2a5 17 | 4=\uc798\ubabb\ub41c \uc0ac\uc6a9\uc790 \uc774\ub984 \ub610\ub294 \ube44\ubc00\ubc88\ud638 18 | 5=\uc5f0\uacb0\ud560 \uc218 \uc788\ub294 \uad8c\ud55c\uc774 \ubd80\uc5ec\ub418\uc9c0 \uc54a\uc74c 19 | 6=\uc608\uc0c1\uce58 \ubabb\ud55c \uc624\ub958 20 | 32000=\uc11c\ubc84\uc5d0\uc11c \uc751\ub2f5\uc744 \uae30\ub2e4\ub9ac\ub294 \uc911 \uc81c\ud55c\uc2dc\uac04 \ucd08\uacfc 21 | 32100=\ud074\ub77c\uc774\uc5b8\ud2b8\uac00 \uc5f0\uacb0\ub428 22 | 32101=\ud074\ub77c\uc774\uc5b8\ud2b8\uac00 \uc5f0\uacb0\uc774 \ub04a\uae40 23 | 32102=\ud604\uc7ac \ud074\ub77c\uc774\uc5b8\ud2b8\uac00 \uc5f0\uacb0\uc744 \ub04a\ub294 \uc911 24 | 32103=\uc11c\ubc84\uc5d0 \uc5f0\uacb0\ud560 \uc218 \uc5c6\uc74c 25 | 32104=\ud074\ub77c\uc774\uc5b8\ud2b8\uac00 \uc5f0\uacb0\ub418\uc9c0 \uc54a\uc74c 26 | 32105=\uc9c0\uc815\ub41c SocketFactory \uc720\ud615\uc774 \ube0c\ub85c\ucee4 URI\uc640 \uc77c\uce58\ud558\uc9c0 \uc54a\uc74c 27 | 32106=SSL \uad6c\uc131 \uc624\ub958 28 | 32107=\ucf5c\ubc31 \uba54\uc18c\ub4dc\ub85c\ubd80\ud130 \uc5f0\uacb0\uc744 \ub04a\ub294 \uac83\uc774 \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc74c 29 | 32108=\uc778\uc2dd\ub418\uc9c0 \uc54a\uc740 \ud328\ud0b7 30 | 32109=\uc5f0\uacb0 \uc720\uc2e4 31 | 32110=\uc5f0\uacb0\uc774 \uc774\ubbf8 \uc9c4\ud589 \uc911\uc784 32 | 32111=\ud074\ub77c\uc774\uc5b8\ud2b8\uac00 \ub2eb\ud798 33 | 32200=\uc9c0\uc18d \ud30c\uc77c\uc744 \uc774\ubbf8 \uc0ac\uc6a9 \uc911 34 | 32201=\ud1a0\ud070\uc774 \uc774\ubbf8 \uc0ac\uc6a9 \uc911\uc784 35 | 32202=\ub108\ubb34 \ub9ce\uc740 \ubc1c\ud589\uc774 \uc9c4\ud589 \uc911\uc784 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_pl.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=Niepoprawna wersja protoko\u0142u 15 | 2=Niepoprawny identyfikator klienta 16 | 3=Broker niedost\u0119pny 17 | 4=Niepoprawna nazwa u\u017cytkownika lub has\u0142o 18 | 5=Brak autoryzacji do nawi\u0105zania po\u0142\u0105czenia 19 | 6=Nieoczekiwany b\u0142\u0105d 20 | 32000=Przekroczono limit czasu oczekiwania na odpowied\u017a z serwera 21 | 32100=Po\u0142\u0105czenie z klientem zosta\u0142o nawi\u0105zane 22 | 32101=Po\u0142\u0105czenie z klientem zosta\u0142o roz\u0142\u0105czone 23 | 32102=Klient roz\u0142\u0105cza si\u0119 24 | 32103=Nie mo\u017cna nawi\u0105za\u0107 po\u0142\u0105czenia z serwerem 25 | 32104=Po\u0142\u0105czenie z klientem nie jest nawi\u0105zane 26 | 32105=Podany typ fabryki SocketFactory nie jest zgodny z identyfikatorem URI brokera 27 | 32106=B\u0142\u0105d konfiguracji protoko\u0142u SSL 28 | 32107=Roz\u0142\u0105czenie nie jest dozwolone w metodzie procedury zwrotnej 29 | 32108=Nierozpoznany pakiet 30 | 32109=Utracono po\u0142\u0105czenie 31 | 32110=Operacja nawi\u0105zywania po\u0142\u0105czenia jest ju\u017c w toku 32 | 32111=Klient zosta\u0142 zamkni\u0119ty 33 | 32200=Trwa\u0142o\u015b\u0107 jest ju\u017c w u\u017cyciu 34 | 32201=Znacznik jest ju\u017c w u\u017cyciu 35 | 32202=Zbyt wiele operacji publikowania jest w toku 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_pt_BR.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=Vers\u00e3o de protocolo inv\u00e1lida 15 | 2=ID de cliente inv\u00e1lido 16 | 3=Broker indispon\u00edvel 17 | 4=Nome de usu\u00e1rio ou senha inv\u00e1lidos 18 | 5=N\u00e3o autorizado a conectar 19 | 6=Erro inesperado 20 | 32000=Tempo limite atingido ao aguardar por uma resposta do servidor 21 | 32100=O cliente est\u00e1 conectado 22 | 32101=O cliente est\u00e1 desconectado 23 | 32102=Cliente desconectando atualmente 24 | 32103=N\u00e3o \u00e9 poss\u00edvel se conectar ao servidor 25 | 32104=O cliente n\u00e3o est\u00e1 conectado 26 | 32105=O tipo SocketFactory especificado n\u00e3o corresponde ao URI do broker 27 | 32106=Erro de configura\u00e7\u00e3o de SSL 28 | 32107=A desconex\u00e3o n\u00e3o \u00e9 permitida a partir de um m\u00e9todo de retorno de chamada 29 | 32108=Pacote n\u00e3o reconhecido 30 | 32109=Conex\u00e3o perdida 31 | 32110=A conex\u00e3o j\u00e1 est\u00e1 em andamento 32 | 32111=O cliente foi encerrado 33 | 32200=Persist\u00eancia j\u00e1 em uso 34 | 32201=O token j\u00e1 est\u00e1 em uso 35 | 32202=Muitas publica\u00e7\u00f5es em andamento 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_ru.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=\u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 15 | 2=\u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0418\u0414 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 16 | 3=\u041f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d 17 | 4=\u041e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u043f\u0430\u0440\u043e\u043b\u044c 18 | 5=\u041d\u0435\u0442 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 19 | 6=\u041d\u0435\u043f\u0440\u0435\u0434\u0432\u0438\u0434\u0435\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 20 | 32000=\u0422\u0430\u043c-\u0430\u0443\u0442 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 21 | 32100=\u041a\u043b\u0438\u0435\u043d\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d 22 | 32101=\u041a\u043b\u0438\u0435\u043d\u0442 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d 23 | 32102=\u041a\u043b\u0438\u0435\u043d\u0442 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f 24 | 32103=\u041d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 25 | 32104=\u041a\u043b\u0438\u0435\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d 26 | 32105=\u0422\u0438\u043f SocketFactory \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 URI \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430 27 | 32106=\u041e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 SSL 28 | 32107=\u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 29 | 32108=\u041d\u0435\u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 30 | 32109=\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u043e 31 | 32110=\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 32 | 32111=\u041a\u043b\u0438\u0435\u043d\u0442 \u0437\u0430\u043a\u0440\u044b\u0442 33 | 32200=\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 34 | 32201=\u041c\u0430\u0440\u043a\u0435\u0440 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 35 | 32202=\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_zh_CN.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=\u65e0\u6548\u534f\u8bae\u7248\u672c 15 | 2=\u65e0\u6548\u5ba2\u6237\u673a\u6807\u8bc6 16 | 3=\u4ee3\u7406\u7a0b\u5e8f\u4e0d\u53ef\u7528 17 | 4=\u9519\u8bef\u7684\u7528\u6237\u540d\u6216\u5bc6\u7801 18 | 5=\u65e0\u6743\u8fde\u63a5 19 | 6=\u610f\u5916\u9519\u8bef 20 | 32000=\u7b49\u5f85\u6765\u81ea\u670d\u52a1\u5668\u7684\u54cd\u5e94\u65f6\u8d85\u65f6 21 | 32100=\u5df2\u8fde\u63a5\u5ba2\u6237\u673a 22 | 32101=\u5df2\u65ad\u5f00\u5ba2\u6237\u673a\u8fde\u63a5 23 | 32102=\u5ba2\u6237\u673a\u6b63\u5728\u65ad\u5f00\u8fde\u63a5 24 | 32103=\u65e0\u6cd5\u8fde\u63a5\u81f3\u670d\u52a1\u5668 25 | 32104=\u5ba2\u6237\u673a\u672a\u8fde\u63a5 26 | 32105=\u6307\u5b9a\u7684 SocketFactory \u7c7b\u578b\u4e0e\u4ee3\u7406\u7a0b\u5e8f URI \u4e0d\u5339\u914d 27 | 32106=SSL \u914d\u7f6e\u9519\u8bef 28 | 32107=\u4e0d\u5141\u8bb8\u901a\u8fc7\u56de\u8c03\u65b9\u6cd5\u65ad\u5f00\u8fde\u63a5 29 | 32108=\u4e0d\u53ef\u8bc6\u522b\u7684\u5305 30 | 32109=\u5df2\u65ad\u5f00\u8fde\u63a5 31 | 32110=\u5df2\u5728\u8fdb\u884c\u8fde\u63a5 32 | 32111=\u5ba2\u6237\u673a\u5df2\u5173\u95ed 33 | 32200=\u6301\u4e45\u6027\u5df2\u5728\u4f7f\u7528\u4e2d 34 | 32201=\u4ee4\u724c\u5df2\u5728\u4f7f\u7528\u4e2d 35 | 32202=\u6b63\u5728\u8fdb\u884c\u8fc7\u591a\u7684\u53d1\u5e03 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/nls/messages_zh_TW.properties: -------------------------------------------------------------------------------- 1 | #/* 2 | # * Copyright (c) 2009, 2012 IBM Corp. 3 | # * 4 | # * All rights reserved. This program and the accompanying materials 5 | # * are made available under the terms of the Eclipse Public License v1.0 6 | # * which accompanies this distribution, and is available at 7 | # * http://www.eclipse.org/legal/epl-v10.html 8 | # * 9 | # * Contributors: 10 | # * Dave Locke - initial API and implementation and/or initial documentation 11 | # */ 12 | # NLS_MESSAGEFORMAT_VAR 13 | # NLS_ENCODING=UNICODE 14 | 1=\u901a\u8a0a\u5354\u5b9a\u7248\u672c\u7121\u6548 15 | 2=\u7528\u6236\u7aef ID \u7121\u6548 16 | 3=\u5206\u914d\u7ba1\u7406\u7cfb\u7d71\u7121\u6cd5\u4f7f\u7528 17 | 4=\u4f7f\u7528\u8005\u540d\u7a31\u6216\u5bc6\u78bc\u4e0d\u7576 18 | 5=\u672a\u7372\u6388\u6b0a\u9023\u63a5 19 | 6=\u975e\u9810\u671f\u7684\u932f\u8aa4 20 | 32000=\u7b49\u5f85\u4f3a\u670d\u5668\u7684\u56de\u61c9\u6642\u903e\u6642 21 | 32100=\u5df2\u9023\u63a5\u7528\u6236\u7aef 22 | 32101=\u5df2\u4e2d\u65b7\u7528\u6236\u7aef\u7684\u9023\u63a5 23 | 32102=\u7528\u6236\u7aef\u76ee\u524d\u6b63\u5728\u4e2d\u65b7\u9023\u7dda 24 | 32103=\u7121\u6cd5\u9023\u63a5\u5230\u4f3a\u670d\u5668 25 | 32104=\u7528\u6236\u7aef\u672a\u9023\u63a5 26 | 32105=\u6307\u5b9a\u7684 SocketFactory \u985e\u578b\u8207\u5206\u914d\u7ba1\u7406\u7cfb\u7d71 URI \u4e0d\u7b26 27 | 32106=SSL \u914d\u7f6e\u932f\u8aa4 28 | 32107=\u4e0d\u5bb9\u8a31\u8207\u56de\u547c\u65b9\u6cd5\u4e2d\u65b7\u9023\u7dda 29 | 32108=\u5c01\u5305\u7121\u6cd5\u8fa8\u8b58 30 | 32109=\u9023\u7dda\u907a\u5931 31 | 32110=\u9023\u63a5\u5df2\u5728\u9032\u884c\u4e2d 32 | 32111=\u5df2\u95dc\u9589\u7528\u6236\u7aef 33 | 32200=\u6301\u7e8c\u6027\u5df2\u5728\u4f7f\u7528\u4e2d 34 | 32201=\u8a18\u865f\u5df2\u5728\u4f7f\u7528\u4e2d 35 | 32202=\u592a\u591a\u767c\u4f48\u9032\u884c\u4e2d 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/security/SimpleBase64Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.security; 13 | 14 | public class SimpleBase64Encoder { 15 | 16 | // if this string is changed, then the decode method must also be adapted. 17 | private final static String PWDCHARS_STRING = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 18 | private final static char[] PWDCHARS_ARRAY = PWDCHARS_STRING.toCharArray(); 19 | 20 | /** 21 | * Encodes an array of byte into a string of printable ASCII characters 22 | * using a base-64 encoding. 23 | * @param bytes The array of bytes to e encoded 24 | * @return The encoded array. 25 | */ 26 | public static String encode(byte[] bytes) { 27 | // Allocate a string buffer. 28 | int len = bytes.length; 29 | final StringBuffer encoded = new StringBuffer((len+2)/3*4); 30 | int i=0; 31 | int j=len; 32 | while(j>=3){ 33 | encoded.append(to64((((bytes[i] & 0xff) << 16) 34 | | (int) ((bytes[i+1] & 0xff) << 8) | (int) (bytes[i+2] & 0xff)),4)); 35 | i+=3; 36 | j-=3; 37 | } 38 | // j==2 | j==1 | j==0 39 | if(j==2) { 40 | // there is a rest of 2 bytes. This encodes into 3 chars. 41 | encoded.append(to64(((bytes[i] &0xff)<<8) | ((bytes[i+1] & 0xff)),3)); 42 | } 43 | if(j==1) { 44 | // there is a rest of 1 byte. This encodes into 1 char. 45 | encoded.append(to64(((bytes[i] & 0xff)),2)); 46 | } 47 | return encoded.toString(); 48 | } 49 | 50 | public static byte[] decode(String string) { 51 | byte[] encoded=string.getBytes(); 52 | int len=encoded.length; 53 | byte[] decoded=new byte[len*3/4]; 54 | int i=0; 55 | int j=len; 56 | int k=0; 57 | while(j>=4) { 58 | long d=from64(encoded, i, 4); 59 | j-=4; 60 | i+=4; 61 | for(int l=2;l>=0;l--) { 62 | decoded[k+l]=(byte) (d & 0xff); 63 | d=d >>8; 64 | } 65 | k+=3; 66 | } 67 | // j==3 | j==2 68 | if(j==3) { 69 | long d=from64(encoded, i, 3); 70 | for(int l=1;l>=0;l--) { 71 | decoded[k+l]=(byte) (d & 0xff); 72 | d=d >>8; 73 | } 74 | } 75 | if(j==2) { 76 | long d=from64(encoded, i, 2); 77 | decoded[k]=(byte) (d & 0xff); 78 | } 79 | return decoded; 80 | } 81 | 82 | /* the core conding routine. Translates an input integer into 83 | * a string of the given length.*/ 84 | private final static String to64(long input, int size) { 85 | final StringBuffer result = new StringBuffer(size); 86 | while (size > 0) { 87 | size--; 88 | result.append(PWDCHARS_ARRAY[((int) (input & 0x3f))]); 89 | input = input >> 6; 90 | } 91 | return result.toString(); 92 | } 93 | 94 | /* 95 | * The reverse operation of to64 96 | */ 97 | private final static long from64(byte[] encoded, int idx, int size) { 98 | long res=0; 99 | int f=0; 100 | while(size>0) { 101 | size--; 102 | long r=0; 103 | // convert encoded[idx] back into a 6-bit value. 104 | byte d=encoded[idx++]; 105 | if(d=='/') { 106 | r=1; 107 | } 108 | if(d>='0' && d<='9') { 109 | r=2+d-'0'; 110 | } 111 | if(d>='A' && d<='Z') { 112 | r=12+d-'A'; 113 | } 114 | if(d>='a' && d<='z') { 115 | r=38+d-'a'; 116 | } 117 | res=res+((long)r << f); 118 | f+=6; 119 | } 120 | return res; 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/CountingInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | 17 | /** 18 | * An input stream that counts the bytes read from it. 19 | */ 20 | public class CountingInputStream extends InputStream { 21 | private InputStream in; 22 | private int counter; 23 | 24 | /** 25 | * Constructs a new CountingInputStream wrapping the supplied 26 | * input stream. 27 | */ 28 | public CountingInputStream(InputStream in) { 29 | this.in = in; 30 | this.counter = 0; 31 | } 32 | 33 | public int read() throws IOException { 34 | try { 35 | int i = in.read(); 36 | if (i != -1) { 37 | counter++; 38 | } 39 | return i; 40 | } catch (Exception e) { 41 | throw new IOException(); 42 | } 43 | 44 | } 45 | 46 | /** 47 | * Returns the number of bytes read since the last reset. 48 | */ 49 | public int getCounter() { 50 | return counter; 51 | } 52 | 53 | /** 54 | * Resets the counter to zero. 55 | */ 56 | public void resetCounter() { 57 | counter = 0; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttAck.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | 15 | /** 16 | * Abstract super-class of all acknowledgement messages. 17 | */ 18 | public abstract class MqttAck extends MqttWireMessage { 19 | public MqttAck(byte type) { 20 | super(type); 21 | } 22 | 23 | protected byte getMessageInfo() { 24 | return 0; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttConnack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayInputStream; 15 | import java.io.DataInputStream; 16 | import java.io.IOException; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | 20 | 21 | /** 22 | * An on-the-wire representation of an MQTT CONNACK. 23 | */ 24 | public class MqttConnack extends MqttAck { 25 | private int returnCode; 26 | 27 | public MqttConnack(byte info, byte[] variableHeader) throws Exception { 28 | super(MqttWireMessage.MESSAGE_TYPE_CONNACK); 29 | ByteArrayInputStream bais = new ByteArrayInputStream(variableHeader); 30 | DataInputStream dis = new DataInputStream(bais); 31 | dis.readByte(); 32 | returnCode = dis.readUnsignedByte(); 33 | dis.close(); 34 | } 35 | 36 | public int getReturnCode() { 37 | return returnCode; 38 | } 39 | 40 | protected byte[] getVariableHeader() throws MqttException { 41 | // Not needed, as the client never encodes a CONNACK 42 | return new byte[0]; 43 | } 44 | 45 | /** 46 | * Returns whether or not this message needs to include a message ID. 47 | */ 48 | public boolean isMessageIdRequired() { 49 | return false; 50 | } 51 | 52 | public String getKey() { 53 | return new String("Con"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttConnect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayOutputStream; 15 | import java.io.DataOutputStream; 16 | import java.io.IOException; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | import org.eclipse.paho.client.mqttv3.MqttMessage; 20 | 21 | /** 22 | * An on-the-wire representation of an MQTT CONNECT message. 23 | */ 24 | public class MqttConnect extends MqttWireMessage { 25 | private String clientId; 26 | private boolean cleanSession; 27 | private MqttMessage willMessage; 28 | private String userName; 29 | private char[] password; 30 | private int keepAliveInterval; 31 | private String willDestination; 32 | public static String KEY="Con"; 33 | 34 | 35 | public MqttConnect(String clientId, 36 | boolean cleanSession, 37 | int keepAliveInterval, 38 | String userName, 39 | char[] password, 40 | MqttMessage willMessage, 41 | String willDestination) { 42 | super(MqttWireMessage.MESSAGE_TYPE_CONNECT); 43 | this.clientId = clientId; 44 | this.cleanSession = cleanSession; 45 | this.keepAliveInterval = keepAliveInterval; 46 | this.userName = userName; 47 | this.password = password; 48 | this.willMessage = willMessage; 49 | this.willDestination = willDestination; 50 | } 51 | 52 | protected byte getMessageInfo() { 53 | return (byte) 0; 54 | } 55 | 56 | public boolean isCleanSession() { 57 | return cleanSession; 58 | } 59 | 60 | protected byte[] getVariableHeader() throws MqttException { 61 | try { 62 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 63 | DataOutputStream dos = new DataOutputStream(baos); 64 | this.encodeUTF8(dos,"MQIsdp"); 65 | 66 | //****change the version code . write by Quentin***// 67 | //********************for massage id refactor******// 68 | //dos.write(3); 69 | dos.write(19); 70 | //*************************************************// 71 | byte connectFlags = 0; 72 | 73 | if (cleanSession) { 74 | connectFlags |= 0x02; 75 | } 76 | 77 | if (willMessage != null ) { 78 | connectFlags |= 0x04; 79 | connectFlags |= (willMessage.getQos()<<3); 80 | if (willMessage.isRetained()) { 81 | connectFlags |= 0x20; 82 | } 83 | } 84 | 85 | if (userName != null) { 86 | connectFlags |= 0x80; 87 | if (password != null) { 88 | connectFlags |= 0x40; 89 | } 90 | } 91 | dos.write(connectFlags); 92 | dos.writeShort(keepAliveInterval); 93 | dos.flush(); 94 | return baos.toByteArray(); 95 | } catch(IOException ioe) { 96 | throw new MqttException(ioe); 97 | } 98 | } 99 | 100 | public byte[] getPayload() throws MqttException { 101 | try { 102 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 103 | DataOutputStream dos = new DataOutputStream(baos); 104 | this.encodeUTF8(dos,clientId); 105 | 106 | if (willMessage != null) { 107 | this.encodeUTF8(dos,willDestination); 108 | dos.writeShort(willMessage.getPayload().length); 109 | dos.write(willMessage.getPayload()); 110 | } 111 | 112 | if (userName != null) { 113 | this.encodeUTF8(dos,userName); 114 | if (password != null) { 115 | this.encodeUTF8(dos,new String(password)); 116 | } 117 | } 118 | dos.flush(); 119 | return baos.toByteArray(); 120 | } 121 | catch (IOException ex) { 122 | throw new MqttException(ex); 123 | } 124 | } 125 | 126 | /** 127 | * Returns whether or not this message needs to include a message ID. 128 | */ 129 | public boolean isMessageIdRequired() { 130 | return false; 131 | } 132 | 133 | public String getKey() { 134 | return new String(KEY); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttDisconnect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import org.eclipse.paho.client.mqttv3.MqttException; 15 | 16 | /** 17 | * An on-the-wire representation of an MQTT DISCONNECT message. 18 | */ 19 | public class MqttDisconnect extends MqttWireMessage { 20 | public static String KEY="Disc"; 21 | 22 | public MqttDisconnect() { 23 | super(MqttWireMessage.MESSAGE_TYPE_DISCONNECT); 24 | } 25 | 26 | protected byte getMessageInfo() { 27 | return (byte) 0; 28 | } 29 | 30 | protected byte[] getVariableHeader() throws MqttException { 31 | return new byte[0]; 32 | } 33 | 34 | /** 35 | * Returns whether or not this message needs to include a message ID. 36 | */ 37 | public boolean isMessageIdRequired() { 38 | return false; 39 | } 40 | 41 | public String getKey() { 42 | try { 43 | return new String(KEY); 44 | } catch (Exception e) { 45 | return ""; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttExpand.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.paho.client.mqttv3.internal.wire; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.DataOutputStream; 5 | import java.io.IOException; 6 | 7 | import org.eclipse.paho.client.mqttv3.MqttException; 8 | 9 | public class MqttExpand extends MqttWireMessage{ 10 | public static final byte CMD_GET_ALIAS = 1; 11 | public static final byte CMD_GET_ALIAS_ACK = 2; 12 | public static final byte CMD_GET_TOPIC = 3; 13 | public static final byte CMD_GET_TOPIC_ACK = 4; 14 | public static final byte CMD_GET_ALIASLIST = 5; 15 | public static final byte CMD_GET_ALIASLIST_ACK = 6; 16 | public static final byte CMD_PUBLISH = 7; 17 | public static final byte CMD_PUBLISH_ACK = 8; 18 | public static final byte CMD_GET_STATUS = 9; 19 | public static final byte CMD_GET_STATUS_ACK = 10; 20 | public static final byte CMD_GET_STATUS_V2 = 19; 21 | public static final byte CMD_GET_STATUS_ACK_V2 = 20; 22 | public static final byte CMD_GET_TOPIC_V2 = 13; 23 | public static final byte CMD_GET_TOPIC_ACK_V2 = 14; 24 | public static final byte CMD_GET_ALIASLIST_V2 = 15; 25 | public static final byte CMD_GET_ALIASLIST_ACK_V2 = 16; 26 | 27 | public MqttExpand () { 28 | super(MqttWireMessage.MESSAGE_TYPE_EXPAND); 29 | } 30 | 31 | public MqttExpand (String topics, byte command) throws MqttException { 32 | super(MqttWireMessage.MESSAGE_TYPE_EXPAND); 33 | this.command = command; 34 | topic = topics; 35 | setPayload(); 36 | } 37 | protected byte[] encodedPayload = null; 38 | protected String topic = null; 39 | protected byte command ; 40 | 41 | @Override 42 | protected byte[] getVariableHeader() throws MqttException { 43 | try { 44 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 45 | DataOutputStream dos = new DataOutputStream(baos); 46 | 47 | //****change the version code . write by Quentin***// 48 | //********************for massage id refactor******// 49 | //dos.writeShort(msgId); 50 | dos.writeLong(msgId); 51 | //*************************************************// 52 | 53 | dos.flush(); 54 | return baos.toByteArray(); 55 | } 56 | catch (IOException ex) { 57 | throw new MqttException(ex); 58 | } 59 | } 60 | 61 | public boolean isMessageIdRequired() { 62 | // all publishes require a message ID as it's used as the key to the token store 63 | return true; 64 | } 65 | 66 | 67 | 68 | @Override 69 | public byte[] getPayload() throws MqttException { 70 | return encodedPayload; 71 | } 72 | 73 | 74 | 75 | public void setPayload() throws MqttException { 76 | try { 77 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 78 | DataOutputStream dos = new DataOutputStream(baos); 79 | dos.writeByte(command); 80 | if(null != topic) { 81 | byte[] encodedString = topic.getBytes("UTF-8"); 82 | dos.writeChar(topic.length()); 83 | dos.write(encodedString); 84 | } else { 85 | dos.writeChar(0); 86 | } 87 | 88 | //*************************************************// 89 | 90 | dos.flush(); 91 | encodedPayload = baos.toByteArray(); 92 | } 93 | catch (IOException ex) { 94 | throw new MqttException(ex); 95 | } 96 | } 97 | 98 | @Override 99 | protected byte getMessageInfo() { 100 | return (byte) 0; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttExpandAck.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.paho.client.mqttv3.internal.wire; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.DataInputStream; 5 | import java.io.IOException; 6 | 7 | import org.codehaus.jettison.json.JSONObject; 8 | import org.eclipse.paho.client.mqttv3.MqttException; 9 | 10 | public class MqttExpandAck extends MqttAck { 11 | public byte command; 12 | public byte status; 13 | public String result; 14 | 15 | public MqttExpandAck(byte info, byte[] data) { 16 | super(MESSAGE_TYPE_EXPAND); 17 | DataInputStream dis = null; 18 | try { 19 | ByteArrayInputStream bais = new ByteArrayInputStream(data); 20 | CountingInputStream counter = new CountingInputStream(bais); 21 | dis = new DataInputStream(counter); 22 | msgId = dis.readLong(); 23 | byte[] payload = new byte[data.length - counter.getCounter()]; 24 | dis.readFully(payload); 25 | command = payload[0]; 26 | status = payload[1]; 27 | if (payload.length > 2) { 28 | int lenth = getLenth(payload[2], payload[3]); 29 | byte[] msg = new byte[lenth]; 30 | 31 | System.arraycopy(payload, 4, msg, 0, msg.length); 32 | result = new String(msg, "UTF-8"); 33 | if (command == MqttExpand.CMD_GET_STATUS_ACK) { 34 | try { 35 | JSONObject js = new JSONObject(); 36 | js.put("status", result); 37 | result = js.toString(); 38 | } catch (Exception e) { 39 | // YLogger.e("JSONObject", "", e); 40 | } 41 | } else if(command == MqttExpand.CMD_GET_ALIAS_ACK) { 42 | // System.err.println("MqttExpand.CMD_GET_ALIAS_ACK = " + result); 43 | JSONObject js = new JSONObject(); 44 | js.put("alias", result); 45 | result = js.toString(); 46 | 47 | } 48 | // YLogger.d("MqttExpandAck", "result = " + result); 49 | } else { 50 | // YLogger.d("MqttExpandAck", "no data in payload"); 51 | } 52 | 53 | } catch (Exception e) { 54 | // YLogger.e("MqttExpandAck", "", e); 55 | } finally { 56 | if (dis != null) { 57 | try { 58 | dis.close(); 59 | } catch (Exception e) { 60 | 61 | } 62 | } 63 | } 64 | 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return "command " + command + " status " + status + " msg = " + result; 70 | } 71 | 72 | @Override 73 | protected byte[] getVariableHeader() throws MqttException { 74 | // TODO Auto-generated method stub 75 | return null; 76 | } 77 | 78 | public static int getLenth(byte b1, byte b2) throws IOException { 79 | 80 | return ((b1 << 8) & 0xFF00) | b2 & 0xFF; 81 | 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttExpandPublish.java: -------------------------------------------------------------------------------- 1 | package org.eclipse.paho.client.mqttv3.internal.wire; 2 | 3 | 4 | 5 | import io.yunba.java.util.MqttUtil; 6 | 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.DataOutputStream; 9 | import java.io.IOException; 10 | import java.util.ArrayList; 11 | import java.util.HashMap; 12 | import java.util.Iterator; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | import org.codehaus.jettison.json.JSONObject; 17 | import org.eclipse.paho.client.mqttv3.MqttException; 18 | ; 19 | 20 | public class MqttExpandPublish extends MqttExpand { 21 | public MqttExpandPublish () { 22 | super(); 23 | } 24 | 25 | public String msg ; 26 | public JSONObject opts; 27 | public MqttExpandPublish (String topics, String msg, byte command, JSONObject opts) throws MqttException { 28 | super(); 29 | this.command = command; 30 | this.opts = opts; 31 | this.msg = msg; 32 | topic = topics; 33 | setPayload(); 34 | } 35 | 36 | 37 | public void setPayload() throws MqttException { 38 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 39 | DataOutputStream dos = new DataOutputStream(baos); 40 | try { 41 | dos.writeByte(command); 42 | byte[] tlv = getTLVBytes(opts, topic, msg); 43 | if (null != tlv) { 44 | dos.writeChar(tlv.length); 45 | dos.write(tlv); 46 | } else { 47 | dos.writeChar(0); 48 | } 49 | 50 | // *************************************************// 51 | 52 | dos.flush(); 53 | encodedPayload = baos.toByteArray(); 54 | } catch (Exception ex) { 55 | throw new MqttException(-105,ex); 56 | } finally { 57 | try { 58 | dos.close(); 59 | baos.close(); 60 | } catch (Exception e) { 61 | 62 | } 63 | } 64 | } 65 | 66 | 67 | public byte[] getTLVBytes(JSONObject opts, String topic, String msg) { 68 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 69 | DataOutputStream dos = new DataOutputStream(baos); 70 | try { 71 | if (!MqttUtil.isEmpty(topic)) { 72 | dos.writeByte(0); 73 | dos.writeChar(topic.getBytes().length); 74 | dos.write(topic.getBytes("UTF-8")); 75 | } 76 | 77 | if (!MqttUtil.isEmpty(msg)) { 78 | dos.writeByte(1); 79 | dos.writeChar(msg.getBytes().length); 80 | dos.write(msg.getBytes("UTF-8")); 81 | } 82 | if (null != opts && opts.length() > 0) { 83 | Iterator keys = opts.keys(); 84 | 85 | while (keys.hasNext()) { 86 | String key = (String) keys.next(); 87 | String value = opts.getString(key); 88 | int keyToInt = getKey(key); 89 | if (keyToInt != -1) { 90 | dos.writeByte(keyToInt); 91 | dos.writeChar(value.getBytes().length); 92 | dos.write(value.getBytes("UTF-8")); 93 | } 94 | } 95 | } 96 | dos.flush(); 97 | 98 | return baos.toByteArray(); 99 | } catch (Exception ex) { 100 | //YLogger.e("MqttExpandPublish", "", ex); 101 | System.err.println(ex.getMessage()); 102 | return null; 103 | } finally { 104 | try { 105 | dos.close(); 106 | baos.close(); 107 | } catch (Exception e) { 108 | 109 | } 110 | } 111 | } 112 | 113 | 114 | // 0: "topics", 115 | // 1: "payload", 116 | // 2: "platform", 117 | // 3: "time_to_live", 118 | // 4: "time_delay", 119 | // 5: "location", 120 | // 6: "qos", 121 | // 7: "apn_json", 122 | private static Map keys = new HashMap(); 123 | static { 124 | keys.put("platform", 2); 125 | keys.put("time_to_live", 3); 126 | keys.put("time_delay", 4); 127 | keys.put("location", 5); 128 | keys.put("qos", 6); 129 | keys.put("apn_json", 7); 130 | } 131 | public static int getKey(String key) { 132 | try { 133 | if (MqttUtil.isEmpty(key)) return -1; 134 | return keys.get(key); 135 | } catch (Exception e) { 136 | return -1; 137 | } 138 | } 139 | 140 | public static String byte2HexString(byte[] b) { 141 | char[] hex = {'0', '1', '2', '3', '4', '5', '6', '7', 142 | '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; 143 | char[] newChar = new char[b.length * 2]; 144 | for(int i = 0; i < b.length; i++) { 145 | newChar[2 * i] = hex[(b[i] & 0xf0) >> 4]; 146 | newChar[2 * i + 1] = hex[b[i] & 0xf]; 147 | } 148 | return new String(newChar); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayOutputStream; 15 | import java.io.DataInputStream; 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | 19 | import org.eclipse.paho.client.mqttv3.MqttException; 20 | import org.eclipse.paho.client.mqttv3.internal.ExceptionHelper; 21 | 22 | 23 | /** 24 | * An MqttInputStream lets applications read instances of 25 | * MqttWireMessage. 26 | */ 27 | public class MqttInputStream extends InputStream { 28 | private DataInputStream in; 29 | 30 | public MqttInputStream(InputStream in) { 31 | this.in = new DataInputStream(in); 32 | } 33 | 34 | public int read() throws IOException { 35 | return in.read(); 36 | } 37 | 38 | public int available() throws IOException { 39 | return in.available(); 40 | } 41 | 42 | public void close() throws IOException { 43 | in.close(); 44 | } 45 | 46 | /** 47 | * Reads an MqttWireMessage from the stream. 48 | */ 49 | public MqttWireMessage readMqttWireMessage() throws Exception, MqttException { 50 | ByteArrayOutputStream bais = new ByteArrayOutputStream(); 51 | byte first = in.readByte(); 52 | byte type = (byte) ((first >>> 4) & 0x0F); 53 | if ((type < MqttWireMessage.MESSAGE_TYPE_CONNECT) || 54 | (type > MqttWireMessage.MESSAGE_TYPE_EXPAND)) { 55 | // Invalid MQTT message type... 56 | throw ExceptionHelper.createMqttException(MqttException.REASON_CODE_INVALID_MESSAGE); 57 | } 58 | long remLen = MqttWireMessage.readMBI(in).getValue(); 59 | bais.write(first); 60 | // bit silly, we decode it then encode it 61 | bais.write(MqttWireMessage.encodeMBI(remLen)); 62 | byte[] packet = new byte[(int)(bais.size()+remLen)]; 63 | in.readFully(packet,bais.size(),packet.length - bais.size()); 64 | byte[] header = bais.toByteArray(); 65 | System.arraycopy(header,0,packet,0, header.length); 66 | MqttWireMessage message = MqttWireMessage.createWireMessage(packet); 67 | return message; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.BufferedOutputStream; 15 | import java.io.IOException; 16 | import java.io.OutputStream; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | 20 | 21 | /** 22 | * An MqttOutputStream lets applications write instances of 23 | * MqttWireMessage. 24 | */ 25 | public class MqttOutputStream extends OutputStream { 26 | private BufferedOutputStream out; 27 | 28 | public MqttOutputStream(OutputStream out) { 29 | this.out = new BufferedOutputStream(out); 30 | } 31 | 32 | public void close() throws IOException { 33 | out.close(); 34 | } 35 | 36 | public void flush() throws IOException { 37 | out.flush(); 38 | } 39 | 40 | public void write(byte[] b) throws IOException { 41 | out.write(b); 42 | } 43 | 44 | public void write(byte[] b, int off, int len) throws IOException { 45 | out.write(b, off, len); 46 | } 47 | 48 | public void write(int b) throws IOException { 49 | out.write(b); 50 | } 51 | 52 | /** 53 | * Writes an MqttWireMessage to the stream. 54 | */ 55 | public void write(MqttWireMessage message) throws IOException, MqttException { 56 | byte[] bytes = message.getHeader(); 57 | byte[] pl = message.getPayload(); 58 | // out.write(message.getHeader()); 59 | // out.write(message.getPayload()); 60 | out.write(bytes,0,bytes.length); 61 | out.write(pl,0,pl.length); 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttPersistableWireMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import org.eclipse.paho.client.mqttv3.MqttException; 15 | import org.eclipse.paho.client.mqttv3.MqttPersistable; 16 | import org.eclipse.paho.client.mqttv3.MqttPersistenceException; 17 | 18 | public abstract class MqttPersistableWireMessage extends MqttWireMessage 19 | implements MqttPersistable { 20 | 21 | public MqttPersistableWireMessage(byte type) { 22 | super(type); 23 | } 24 | 25 | public byte[] getHeaderBytes() throws MqttPersistenceException { 26 | try { 27 | return getHeader(); 28 | } 29 | catch (MqttException ex) { 30 | throw new MqttPersistenceException(ex.getCause()); 31 | } 32 | } 33 | 34 | public int getHeaderLength() throws MqttPersistenceException { 35 | return getHeaderBytes().length; 36 | } 37 | 38 | public int getHeaderOffset() throws MqttPersistenceException{ 39 | return 0; 40 | } 41 | 42 | // public String getKey() throws MqttPersistenceException { 43 | // return new Integer(getMessageId()).toString(); 44 | // } 45 | 46 | public byte[] getPayloadBytes() throws MqttPersistenceException { 47 | try { 48 | return getPayload(); 49 | } 50 | catch (MqttException ex) { 51 | throw new MqttPersistenceException(ex.getCause()); 52 | } 53 | } 54 | 55 | public int getPayloadLength() throws MqttPersistenceException { 56 | return 0; 57 | } 58 | 59 | public int getPayloadOffset() throws MqttPersistenceException { 60 | return 0; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttPingReq.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import org.eclipse.paho.client.mqttv3.MqttException; 15 | 16 | /** 17 | * An on-the-wire representation of an MQTT PINGREQ message. 18 | */ 19 | public class MqttPingReq extends MqttWireMessage { 20 | public MqttPingReq() { 21 | super(MqttWireMessage.MESSAGE_TYPE_PINGREQ); 22 | } 23 | 24 | /** 25 | * Returns false as message IDs are not required for MQTT 26 | * PINGREQ messages. 27 | */ 28 | public boolean isMessageIdRequired() { 29 | return false; 30 | } 31 | 32 | protected byte[] getVariableHeader() throws MqttException { 33 | return new byte[0]; 34 | } 35 | 36 | protected byte getMessageInfo() { 37 | return 0; 38 | } 39 | 40 | public String getKey() { 41 | return new String("Ping"); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttPingResp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import org.eclipse.paho.client.mqttv3.MqttException; 15 | 16 | 17 | /** 18 | * An on-the-wire representation of an MQTT PINGRESP. 19 | */ 20 | public class MqttPingResp extends MqttAck { 21 | public MqttPingResp(byte info, byte[] variableHeader) { 22 | super(MqttWireMessage.MESSAGE_TYPE_PINGRESP); 23 | } 24 | 25 | protected byte[] getVariableHeader() throws MqttException { 26 | // Not needed, as the client never encodes a PINGRESP 27 | return new byte[0]; 28 | } 29 | 30 | /** 31 | * Returns whether or not this message needs to include a message ID. 32 | */ 33 | public boolean isMessageIdRequired() { 34 | return false; 35 | } 36 | 37 | public String getKey() { 38 | return new String("Ping"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttPubAck.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayInputStream; 15 | import java.io.DataInputStream; 16 | import java.io.IOException; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | 20 | 21 | 22 | /** 23 | * An on-the-wire representation of an MQTT PUBACK message. 24 | */ 25 | public class MqttPubAck extends MqttAck { 26 | public MqttPubAck(byte info, byte[] data) throws IOException { 27 | super(MqttWireMessage.MESSAGE_TYPE_PUBACK); 28 | ByteArrayInputStream bais = new ByteArrayInputStream(data); 29 | DataInputStream dis = new DataInputStream(bais); 30 | msgId = dis.readLong(); 31 | dis.close(); 32 | } 33 | 34 | public MqttPubAck(MqttPublish publish) { 35 | super(MqttWireMessage.MESSAGE_TYPE_PUBACK); 36 | msgId = publish.getMessageId(); 37 | } 38 | 39 | protected byte[] getVariableHeader() throws MqttException { 40 | return encodeMessageId(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttPubComp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayInputStream; 15 | import java.io.DataInputStream; 16 | import java.io.IOException; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | 20 | 21 | 22 | /** 23 | * An on-the-wire representation of an MQTT PUBCOMP message. 24 | */ 25 | public class MqttPubComp extends MqttAck { 26 | public MqttPubComp(byte info, byte[] data) throws IOException { 27 | super(MqttWireMessage.MESSAGE_TYPE_PUBCOMP); 28 | ByteArrayInputStream bais = new ByteArrayInputStream(data); 29 | DataInputStream dis = new DataInputStream(bais); 30 | msgId = dis.readLong(); 31 | dis.close(); 32 | } 33 | 34 | public MqttPubComp(MqttPublish publish) { 35 | super(MqttWireMessage.MESSAGE_TYPE_PUBCOMP); 36 | this.msgId = publish.getMessageId(); 37 | } 38 | 39 | public MqttPubComp(long msgId) { 40 | super(MqttWireMessage.MESSAGE_TYPE_PUBCOMP); 41 | this.msgId = msgId; 42 | } 43 | 44 | protected byte[] getVariableHeader() throws MqttException { 45 | return encodeMessageId(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttPubRec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayInputStream; 15 | import java.io.DataInputStream; 16 | import java.io.IOException; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | 20 | 21 | 22 | /** 23 | * An on-the-wire representation of an MQTT PUBREC message. 24 | */ 25 | public class MqttPubRec extends MqttAck { 26 | public MqttPubRec(byte info, byte[] data) throws IOException { 27 | super(MqttWireMessage.MESSAGE_TYPE_PUBREC); 28 | ByteArrayInputStream bais = new ByteArrayInputStream(data); 29 | DataInputStream dis = new DataInputStream(bais); 30 | msgId = dis.readLong(); 31 | dis.close(); 32 | } 33 | 34 | public MqttPubRec(MqttPublish publish) { 35 | super(MqttWireMessage.MESSAGE_TYPE_PUBREC); 36 | msgId = publish.getMessageId(); 37 | } 38 | 39 | protected byte[] getVariableHeader() throws MqttException { 40 | return encodeMessageId(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttPubRel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayInputStream; 15 | import java.io.DataInputStream; 16 | import java.io.IOException; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | 20 | /** 21 | * An on-the-wire representation of an MQTT PUBREL message. 22 | */ 23 | public class MqttPubRel extends MqttPersistableWireMessage { 24 | 25 | /** 26 | * Createa a pubrel message based on a pubrec 27 | * @param pubRec 28 | */ 29 | public MqttPubRel(MqttPubRec pubRec) { 30 | super(MqttWireMessage.MESSAGE_TYPE_PUBREL); 31 | this.setMessageId(pubRec.getMessageId()); 32 | } 33 | 34 | /** 35 | * Creates a pubrel based on a pubrel set of bytes read fro the network 36 | * @param info 37 | * @param data 38 | * @throws IOException 39 | */ 40 | public MqttPubRel(byte info, byte[] data) throws IOException { 41 | super(MqttWireMessage.MESSAGE_TYPE_PUBREL); 42 | ByteArrayInputStream bais = new ByteArrayInputStream(data); 43 | DataInputStream dis = new DataInputStream(bais); 44 | msgId = dis.readLong(); 45 | dis.close(); 46 | } 47 | 48 | protected byte[] getVariableHeader() throws MqttException { 49 | return encodeMessageId(); 50 | } 51 | 52 | protected byte getMessageInfo() { 53 | return (byte)( 2 | (this.duplicate?8:0)); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttPublish.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayInputStream; 15 | import java.io.ByteArrayOutputStream; 16 | import java.io.DataInputStream; 17 | import java.io.DataOutputStream; 18 | import java.io.IOException; 19 | 20 | import org.eclipse.paho.client.mqttv3.MqttException; 21 | import org.eclipse.paho.client.mqttv3.MqttMessage; 22 | 23 | 24 | /** 25 | * An on-the-wire representation of an MQTT SEND message. 26 | */ 27 | public class MqttPublish extends MqttPersistableWireMessage { 28 | 29 | private MqttMessage message; 30 | private String topicName; 31 | 32 | private byte[] encodedPayload = null; 33 | 34 | public MqttPublish(String name, MqttMessage message) { 35 | super(MqttWireMessage.MESSAGE_TYPE_PUBLISH); 36 | this.topicName = name; 37 | this.message = message; 38 | } 39 | 40 | /** 41 | * Constructs a new MqttPublish object. 42 | * @param info the message info byte 43 | * @param data the variable header and payload bytes 44 | */ 45 | public MqttPublish(byte info, byte[] data) throws MqttException, IOException { 46 | super(MqttWireMessage.MESSAGE_TYPE_PUBLISH); 47 | this.message = new MqttReceivedMessage(); 48 | message.setQos((info >> 1) & 0x03); 49 | if ((info & 0x01) == 0x01) { 50 | message.setRetained(true); 51 | } 52 | if ((info & 0x08) == 0x08) { 53 | ((MqttReceivedMessage) message).setDuplicate(true); 54 | } 55 | 56 | ByteArrayInputStream bais = new ByteArrayInputStream(data); 57 | CountingInputStream counter = new CountingInputStream(bais); 58 | DataInputStream dis = new DataInputStream(counter); 59 | topicName = this.decodeUTF8(dis); 60 | if (message.getQos() > 0) { 61 | msgId = dis.readLong(); 62 | } 63 | byte[] payload = new byte[data.length-counter.getCounter()]; 64 | dis.readFully(payload); 65 | dis.close(); 66 | message.setPayload(payload); 67 | } 68 | 69 | protected byte getMessageInfo() { 70 | byte info = (byte) (message.getQos() << 1); 71 | if (message.isRetained()) { 72 | info |= 0x01; 73 | } 74 | if (message.isDuplicate() || duplicate ) { 75 | info |= 0x08; 76 | } 77 | 78 | return info; 79 | } 80 | 81 | public String getTopicName() { 82 | return topicName; 83 | } 84 | 85 | public MqttMessage getMessage() { 86 | return message; 87 | } 88 | 89 | protected static byte[] encodePayload(MqttMessage message) { 90 | return message.getPayload(); 91 | } 92 | 93 | public byte[] getPayload() throws MqttException { 94 | if (encodedPayload == null) { 95 | encodedPayload = encodePayload(message); 96 | } 97 | return encodedPayload; 98 | } 99 | 100 | public int getPayloadLength() { 101 | int length = 0; 102 | try { 103 | length = getPayload().length; 104 | } catch(MqttException me) { 105 | } 106 | return length; 107 | } 108 | 109 | //****************set msgId to long, by Quentin**// 110 | public void setMessageId(long msgId) { 111 | super.setMessageId(msgId); 112 | if (message instanceof MqttReceivedMessage) { 113 | ((MqttReceivedMessage)message).setMessageId(msgId); 114 | } 115 | } 116 | 117 | protected byte[] getVariableHeader() throws MqttException { 118 | try { 119 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 120 | DataOutputStream dos = new DataOutputStream(baos); 121 | this.encodeUTF8(dos, topicName); 122 | if (message.getQos() > 0) { 123 | 124 | 125 | //****change the version code . write by Quentin***// 126 | //********************for massage id refactor******// 127 | //dos.writeShort(msgId); 128 | dos.writeLong(msgId); 129 | //*************************************************// 130 | } 131 | dos.flush(); 132 | return baos.toByteArray(); 133 | } 134 | catch (IOException ex) { 135 | throw new MqttException(ex); 136 | } 137 | } 138 | 139 | public boolean isMessageIdRequired() { 140 | // all publishes require a message ID as it's used as the key to the token store 141 | return true; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttReceivedMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import org.eclipse.paho.client.mqttv3.MqttMessage; 15 | 16 | public class MqttReceivedMessage extends MqttMessage { 17 | 18 | //****************set msgId to long, by Quentin**// 19 | private long messageId; 20 | //****************set msgId to long, by Quentin**// 21 | public void setMessageId(long msgId) { 22 | this.messageId = msgId; 23 | } 24 | 25 | //****************set msgId to long, by Quentin**// 26 | public long getMessageId() { 27 | return messageId; 28 | } 29 | 30 | // This method exists here to get around the protected visibility of the 31 | // super class method. 32 | public void setDuplicate(boolean value) { 33 | super.setDuplicate(value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttSuback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | import java.io.ByteArrayInputStream; 15 | import java.io.DataInputStream; 16 | import java.io.IOException; 17 | 18 | import org.eclipse.paho.client.mqttv3.MqttException; 19 | 20 | 21 | /** 22 | * An on-the-wire representation of an MQTT SUBACK. 23 | */ 24 | public class MqttSuback extends MqttAck { 25 | private int[] grantedQos; // Not currently made available to anyone. 26 | 27 | public MqttSuback(byte info, byte[] data) throws Exception { 28 | super(MqttWireMessage.MESSAGE_TYPE_SUBACK); 29 | ByteArrayInputStream bais = new ByteArrayInputStream(data); 30 | DataInputStream dis = new DataInputStream(bais); 31 | msgId = dis.readLong(); 32 | int index = 0; 33 | grantedQos = new int[data.length-2]; 34 | int qos = dis.read(); 35 | while (qos != -1 && index < grantedQos.length) { 36 | grantedQos[index] = qos; 37 | index++; 38 | qos = dis.read(); 39 | } 40 | dis.close(); 41 | } 42 | 43 | protected byte[] getVariableHeader() throws MqttException { 44 | // Not needed, as the client never encodes a SUBACK 45 | return new byte[0]; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/internal/wire/MqttSubscribe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.internal.wire; 13 | 14 | 15 | import java.io.ByteArrayOutputStream; 16 | import java.io.DataOutputStream; 17 | import java.io.IOException; 18 | 19 | import org.eclipse.paho.client.mqttv3.MqttException; 20 | import org.eclipse.paho.client.mqttv3.MqttMessage; 21 | 22 | 23 | /** 24 | * An on-the-wire representation of an MQTT SUBSCRIBE message. 25 | */ 26 | public class MqttSubscribe extends MqttWireMessage { 27 | private String[] names; 28 | private int[] qos; 29 | 30 | /** 31 | * Constructor for on an on hte wire MQTT subscribe message 32 | * @param names - one or more topics to subscribe to 33 | * @param qos - the max QOS that each each topic will be subscribed at 34 | */ 35 | public MqttSubscribe(String[] names, int[] qos) { 36 | super(MqttWireMessage.MESSAGE_TYPE_SUBSCRIBE); 37 | this.names = names; 38 | this.qos = qos; 39 | 40 | if (names.length != qos.length) { 41 | throw new IllegalArgumentException(); 42 | } 43 | 44 | for (int i=0;iSimpleFormatter object. 19 | */ 20 | public SimpleLogFormatter() { 21 | super(); 22 | } 23 | 24 | /** 25 | * Format the logrecord as a single line with well defined columns. 26 | */ 27 | public String format(LogRecord r) { 28 | StringBuffer sb = new StringBuffer(); 29 | sb.append(r.getLevel().getName()+"\t"); 30 | sb.append(MessageFormat.format("{0, date, yy-MM-dd} {0, time, kk:mm:ss.SSSS} ", 31 | new Object[] { new Date(r.getMillis()) })+"\t"); 32 | String cnm = r.getSourceClassName(); 33 | String cn=""; 34 | if (cnm != null) { 35 | int cnl = cnm.length(); 36 | if (cnl>20) { 37 | cn = r.getSourceClassName().substring(cnl-19); 38 | } else { 39 | char sp[] = {' '}; 40 | StringBuffer sb1= new StringBuffer().append(cnm); 41 | cn = sb1.append(sp,0, 1).toString(); 42 | } 43 | } 44 | sb.append(cn+"\t").append(" "); 45 | sb.append(left(r.getSourceMethodName(),23,' ')+"\t"); 46 | sb.append(r.getThreadID()+"\t"); 47 | sb.append(formatMessage(r)).append(ls); 48 | if (null != r.getThrown()) { 49 | sb.append("Throwable occurred: "); 50 | Throwable t = r.getThrown(); 51 | PrintWriter pw = null; 52 | try { 53 | StringWriter sw = new StringWriter(); 54 | pw = new PrintWriter(sw); 55 | t.printStackTrace(pw); 56 | sb.append(sw.toString()); 57 | } finally { 58 | if (pw != null) { 59 | try { 60 | pw.close(); 61 | } catch (Exception e) { 62 | // ignore 63 | } 64 | } 65 | } 66 | } 67 | return sb.toString(); 68 | } 69 | 70 | /** 71 | * Left justify a string. 72 | * 73 | * @param s the string to justify 74 | * @param width the field width to justify within 75 | * @param fillChar the character to fill with 76 | * 77 | * @return the justified string. 78 | */ 79 | public static String left(String s, int width, char fillChar) { 80 | if (s.length() >= width) { 81 | return s; 82 | } 83 | StringBuffer sb = new StringBuffer(width); 84 | sb.append(s); 85 | for (int i = width - s.length(); --i >= 0;) { 86 | sb.append(fillChar); 87 | } 88 | return sb.toString(); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/logging/jsr47min.properties: -------------------------------------------------------------------------------- 1 | # Properties file which configures the operation of the JDK logging facility. 2 | # 3 | # The configuration in this file is the suggesgted configuration 4 | # for collecting trace for helping debug problems related to the 5 | # Paho MQTT client. It configures trace to be continuosly collected 6 | # in memory with minimal impact on performance. 7 | # 8 | # When the push trigger (by default a Severe level message) or a 9 | # specific request is made to "push" the in memory trace then it 10 | # is "pushed" to the configured target handler. By default 11 | # this is the standard java.util.logging.FileHandler. The Paho Debug 12 | # class can be used to push the memory trace to its target 13 | # 14 | # To enable trace either: 15 | # - use this properties file as is and set the logging facility up 16 | # to use it by configuring the util logging system property e.g. 17 | # 18 | # >java -Djava.util.logging.config.file=\jsr47min.properties 19 | # 20 | # - This contents of this file can also be merged with another 21 | # java.util.logging config file to ensure provide wider logging 22 | # and trace including Paho trace 23 | 24 | # Global logging properties. 25 | # ------------------------------------------ 26 | # The set of handlers to be loaded upon startup. 27 | # Comma-separated list of class names. 28 | # - Root handlers are not enabled by default - just handlers on the Paho packages. 29 | #handlers=java.util.logging.MemoryHandler,java.util.logging.FileHandler, java.util.logging.ConsoleHandler 30 | 31 | # Default global logging level. 32 | # Loggers and Handlers may override this level 33 | #.level=INFO 34 | 35 | # Loggers 36 | # ------------------------------------------ 37 | # A memoryhandler is attached to the paho packages 38 | # and the level specified to collected all trace related 39 | # to paho packages. This will override any root/global 40 | # level handlers if set. 41 | org.eclipse.paho.client.mqttv3.handlers=java.util.logging.MemoryHandler 42 | org.eclipse.paho.client.mqttv3.level=ALL 43 | # It is possible to set more granular trace on a per class basis e.g. 44 | #org.eclipse.paho.client.mqttv3.internal.ClientComms.level=ALL 45 | 46 | # Handlers 47 | # ----------------------------------------- 48 | # Note: the target handler that is associated with the MemoryHandler is not a root handler 49 | # and hence not returned when getting the handlers from root. It appears accessing 50 | # target handler programatically is not possible as target is a private variable in 51 | # class MemoryHandler 52 | java.util.logging.MemoryHandler.level=FINEST 53 | java.util.logging.MemoryHandler.size=10000 54 | java.util.logging.MemoryHandler.push=SEVERE 55 | java.util.logging.MemoryHandler.target=java.util.logging.FileHandler 56 | #java.util.logging.MemoryHandler.target=java.util.logging.ConsoleHandler 57 | 58 | 59 | # --- FileHandler --- 60 | # Override of global logging level 61 | java.util.logging.FileHandler.level=ALL 62 | 63 | # Naming style for the output file: 64 | # (The output file is placed in the directory 65 | # defined by the "user.home" System property.) 66 | # See java.util.logging for more options 67 | java.util.logging.FileHandler.pattern=%h/paho%u.log 68 | 69 | # Limiting size of output file in bytes: 70 | java.util.logging.FileHandler.limit=200000 71 | 72 | # Number of output files to cycle through, by appending an 73 | # integer to the base file name: 74 | java.util.logging.FileHandler.count=3 75 | 76 | # Style of output (Simple or XML): 77 | java.util.logging.FileHandler.formatter=org.eclipse.paho.client.mqttv3.logging.SimpleLogFormatter 78 | 79 | # --- ConsoleHandler --- 80 | # Override of global logging level 81 | #java.util.logging.ConsoleHandler.level=INFO 82 | #java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter 83 | #java.util.logging.ConsoleHandler.formatter=org.eclipse.paho.client.mqttv3.logging.SimpleLogFormatter 84 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/logging/package.html: -------------------------------------------------------------------------------- 1 | 2 | Provides facilities to write and format log and trace to help debug problems. 3 | 4 |

The default log and trace facility uses Java's build in log facility:- 5 | java.util.logging. For systems where this is not available or where 6 | an alternative logging framework is required the logging facility can be 7 | replaced using {@link org.eclipse.paho.client.mqttv3.logging.LoggerFactory#setLogger(String)} 8 | which takes an implementation of the {@link org.eclipse.paho.client.mqttv3.logging.Logger} 9 | interface. 10 | 11 |

A sample java.util.logging properties file - jsr47min.properties is provided that demonstrates 12 | how to run with a memory based trace facility that runs with minimal performance 13 | overhead. The memory buffer can be dumped when a log/trace record is written matching 14 | the MemoryHandlers trigger level or when the push method is invoked on the MemoryHandler. 15 | {@link org.eclipse.paho.client.mqttv3.util.Debug Debug} provides method to make it easy 16 | to dump the memory buffer as well as other useful debug info. 17 | 18 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/persist/MemoryPersistence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.persist; 13 | 14 | import java.util.Enumeration; 15 | import java.util.Hashtable; 16 | 17 | import org.eclipse.paho.client.mqttv3.MqttClientPersistence; 18 | import org.eclipse.paho.client.mqttv3.MqttPersistable; 19 | import org.eclipse.paho.client.mqttv3.MqttPersistenceException; 20 | 21 | /** 22 | * Persistence that uses memory 23 | * 24 | * In cases where reliability is not required across client or device 25 | * restarts memory this memory peristence can be used. In cases where 26 | * reliability is required like when clean session is set to false 27 | * then a non-volatile form of persistence should be used. 28 | * 29 | */ 30 | public class MemoryPersistence implements MqttClientPersistence { 31 | 32 | private Hashtable data; 33 | 34 | /* (non-Javadoc) 35 | * @see org.eclipse.paho.client.mqttv3.MqttClientPersistence#close() 36 | */ 37 | public void close() throws MqttPersistenceException { 38 | data.clear(); 39 | } 40 | 41 | /* (non-Javadoc) 42 | * @see org.eclipse.paho.client.mqttv3.MqttClientPersistence#keys() 43 | */ 44 | public Enumeration keys() throws MqttPersistenceException { 45 | return data.keys(); 46 | } 47 | 48 | /* (non-Javadoc) 49 | * @see org.eclipse.paho.client.mqttv3.MqttClientPersistence#get(java.lang.String) 50 | */ 51 | public MqttPersistable get(String key) throws MqttPersistenceException { 52 | return (MqttPersistable)data.get(key); 53 | } 54 | 55 | /* (non-Javadoc) 56 | * @see org.eclipse.paho.client.mqttv3.MqttClientPersistence#open(java.lang.String, java.lang.String) 57 | */ 58 | public void open(String clientId, String serverURI) throws MqttPersistenceException { 59 | this.data = new Hashtable(); 60 | } 61 | 62 | /* (non-Javadoc) 63 | * @see org.eclipse.paho.client.mqttv3.MqttClientPersistence#put(java.lang.String, org.eclipse.paho.client.mqttv3.MqttPersistable) 64 | */ 65 | public void put(String key, MqttPersistable persistable) throws MqttPersistenceException { 66 | data.put(key, persistable); 67 | } 68 | 69 | /* (non-Javadoc) 70 | * @see org.eclipse.paho.client.mqttv3.MqttClientPersistence#remove(java.lang.String) 71 | */ 72 | public void remove(String key) throws MqttPersistenceException { 73 | data.remove(key); 74 | } 75 | 76 | /* (non-Javadoc) 77 | * @see org.eclipse.paho.client.mqttv3.MqttClientPersistence#clear() 78 | */ 79 | public void clear() throws MqttPersistenceException { 80 | data.clear(); 81 | } 82 | 83 | /* (non-Javadoc) 84 | * @see org.eclipse.paho.client.mqttv3.MqttClientPersistence#containsKey(java.lang.String) 85 | */ 86 | public boolean containsKey(String key) throws MqttPersistenceException { 87 | return data.containsKey(key); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/persist/package.html: -------------------------------------------------------------------------------- 1 | 2 | Contains implementations of the MqttClientPersistence interface. 3 | 4 |

5 | An MQTT client needs a persistence mechanism to store messages while they 6 | are in the process of being delivered. This package contains several 7 | implementations of the interface. If a persistence class is not 8 | specified on the constructor to an MQTT client, 9 | {@link org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence MqttDefaultFilePersistence} 10 | is used by default. 11 | 12 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/util/Debug.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2012 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Dave Locke - initial API and implementation and/or initial documentation 11 | */ 12 | package org.eclipse.paho.client.mqttv3.util; 13 | 14 | import java.util.Enumeration; 15 | import java.util.Properties; 16 | 17 | import org.eclipse.paho.client.mqttv3.internal.ClientComms; 18 | import org.eclipse.paho.client.mqttv3.logging.Logger; 19 | import org.eclipse.paho.client.mqttv3.logging.LoggerFactory; 20 | 21 | /** 22 | * Utility to help debug problems with the Paho MQTT client 23 | * Once initialised a call to dumpClientDebug will force any memory trace 24 | * together with pertinent client and system state to the main log facility. 25 | * 26 | * No client wide lock is taken when the dump is progress. This means the 27 | * set of client state may not be consistent as the client can still be 28 | * processing work while the dump is in progress. 29 | */ 30 | public class Debug { 31 | 32 | final static String className = ClientComms.class.getName(); 33 | Logger log = LoggerFactory.getLogger(LoggerFactory.MQTT_CLIENT_MSG_CAT,className); 34 | 35 | static String separator = "=============="; 36 | static String lineSep = System.getProperty("line.separator","\n"); 37 | 38 | String clientID; 39 | ClientComms comms; 40 | 41 | /** 42 | * Set the debug facility up for a specific client 43 | * @param clientID the ID of the client being debugged 44 | * @param comms the ClientComms object of the client being debugged 45 | */ 46 | public Debug(String clientID, ClientComms comms) { 47 | this.clientID = clientID; 48 | this.comms = comms; 49 | log.setResourceName(clientID); 50 | } 51 | 52 | /** 53 | * Dump maximum debug info. 54 | * This includes state specific to a client as well 55 | * as debug that is JVM wide like trace and system properties. 56 | * All state is written as debug log entries. 57 | */ 58 | public void dumpClientDebug() { 59 | dumpClientComms(); 60 | dumpConOptions(); 61 | dumpClientState(); 62 | dumpBaseDebug(); 63 | } 64 | 65 | /** 66 | * Dump of JVM wide debug info. 67 | * This includes trace and system properties. 68 | * Includes trace and system properties 69 | */ 70 | public void dumpBaseDebug() { 71 | dumpVersion(); 72 | dumpSystemProperties(); 73 | dumpMemoryTrace(); 74 | } 75 | 76 | /** 77 | * If memory trace is being used a request is made to push it 78 | * to the target handler. 79 | */ 80 | protected void dumpMemoryTrace() { 81 | log.dumpTrace(); 82 | } 83 | 84 | /** 85 | * Dump information that show the version of the MQTT client being used. 86 | */ 87 | protected void dumpVersion() { 88 | StringBuffer vInfo = new StringBuffer(); 89 | vInfo.append(lineSep+separator+" Version Info "+ separator+lineSep); 90 | vInfo.append(left("Version",20,' ') + ": "+ ClientComms.VERSION + lineSep); 91 | vInfo.append(left("Build Level",20,' ') + ": "+ ClientComms.BUILD_LEVEL + lineSep); 92 | vInfo.append(separator+separator+separator+lineSep); 93 | log.fine(className,"dumpVersion", vInfo.toString()); 94 | } 95 | 96 | /** 97 | * Dump the current set of system.properties to a log record 98 | */ 99 | public void dumpSystemProperties() { 100 | 101 | Properties sysProps = System.getProperties(); 102 | log.fine(className,"dumpSystemProperties", dumpProperties(sysProps, "SystemProperties").toString()); 103 | } 104 | 105 | /** 106 | * Dump interesting variables from ClientState 107 | */ 108 | public void dumpClientState() { 109 | Properties props = null; 110 | if (comms != null && comms.getClientState() != null ) { 111 | props = comms.getClientState().getDebug(); 112 | log.fine(className,"dumpClientState", dumpProperties(props, clientID + " : ClientState").toString()); 113 | } 114 | } 115 | 116 | /** 117 | * Dump interesting variables from ClientComms 118 | */ 119 | public void dumpClientComms() { 120 | Properties props = null; 121 | if (comms != null) { 122 | props = comms.getDebug(); 123 | log.fine(className,"dumpClientComms", dumpProperties(props, clientID + " : ClientComms").toString()); 124 | } 125 | } 126 | 127 | /** 128 | * Dump Connection options 129 | */ 130 | public void dumpConOptions() { 131 | Properties props = null; 132 | if (comms != null) { 133 | props = comms.getConOptions().getDebug(); 134 | log.fine(className,"dumpConOptions", dumpProperties(props, clientID + " : Connect Options").toString()); 135 | } 136 | } 137 | 138 | 139 | /** 140 | * Return a set of properties as a formatted string 141 | */ 142 | public static String dumpProperties(Properties props, String name) { 143 | 144 | StringBuffer propStr = new StringBuffer(); 145 | Enumeration propsE = props.propertyNames(); 146 | propStr.append(lineSep+separator+" "+name+" "+ separator+lineSep); 147 | while (propsE.hasMoreElements()) { 148 | String key = (String)propsE.nextElement(); 149 | propStr.append(left(key,28,' ') + ": "+ props.get(key)+lineSep); 150 | } 151 | propStr.append(separator+separator+separator+lineSep); 152 | 153 | return propStr.toString(); 154 | } 155 | 156 | /** 157 | * Left justify a string. 158 | * 159 | * @param s the string to justify 160 | * @param width the field width to justify within 161 | * @param fillChar the character to fill with 162 | * 163 | * @return the justified string. 164 | */ 165 | public static String left(String s, int width, char fillChar) { 166 | if (s.length() >= width) { 167 | return s; 168 | } 169 | StringBuffer sb = new StringBuffer(width); 170 | sb.append(s); 171 | for (int i = width - s.length(); --i >= 0;) { 172 | sb.append(fillChar); 173 | } 174 | return sb.toString(); 175 | } 176 | 177 | } 178 | -------------------------------------------------------------------------------- /src/org/eclipse/paho/client/mqttv3/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | Provides helpers and utilities. 3 | 4 | 5 | -------------------------------------------------------------------------------- /yunba-java-sdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yunba/yunba-java-sdk/333ae6d7694fb70baa21c8abe29a88dc47342b5e/yunba-java-sdk.jar --------------------------------------------------------------------------------