Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug: 459142 - WebSocket support for the Java client
With this change, you can now use the Java client to connect to MQTT brokers supporting WebSockets. To do this, use either ws or wss as the protocol type in the URI. For example: ws://localhost:1883 or wss://localhost:1883 Signed-off-by: James Sutton <james.sutton@uk.ibm.com> Change-Id: Iefa994ad5950ea2a66a4733512f62a2755fa0f82
- Loading branch information
Showing
9 changed files
with
956 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/websocket/Base64.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2014 IBM Corp. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* Contributors: | ||
* James Sutton - Bug 459142 - WebSocket support for the Java client. | ||
*/ | ||
package org.eclipse.paho.client.mqttv3.internal.websocket; | ||
|
||
import java.util.prefs.AbstractPreferences; | ||
import java.util.prefs.BackingStoreException; | ||
|
||
public class Base64 { | ||
|
||
private static final Base64 instance = new Base64(); | ||
private static final Base64Encoder encoder = instance.new Base64Encoder(); | ||
|
||
public static String encode (String s){ | ||
encoder.putByteArray("akey", s.getBytes()); | ||
String result = encoder.getBase64String(); | ||
return result; | ||
} | ||
|
||
public static String encodeBytes (byte[] b){ | ||
encoder.putByteArray("aKey", b); | ||
String result = encoder.getBase64String(); | ||
return result; | ||
|
||
} | ||
|
||
public class Base64Encoder extends AbstractPreferences { | ||
|
||
private String base64String = null; | ||
|
||
public Base64Encoder() { | ||
super(null, ""); | ||
} | ||
|
||
|
||
protected void putSpi(String key, String value) { | ||
base64String = value; | ||
} | ||
|
||
public String getBase64String() { | ||
return base64String; | ||
} | ||
|
||
|
||
protected String getSpi(String key) { | ||
return null; | ||
} | ||
|
||
|
||
protected void removeSpi(String key) { | ||
} | ||
|
||
|
||
protected void removeNodeSpi() throws BackingStoreException { | ||
|
||
} | ||
|
||
|
||
protected String[] keysSpi() throws BackingStoreException { | ||
return null; | ||
} | ||
|
||
|
||
protected String[] childrenNamesSpi() throws BackingStoreException { | ||
return null; | ||
} | ||
|
||
|
||
protected AbstractPreferences childSpi(String name) { | ||
return null; | ||
} | ||
|
||
|
||
protected void syncSpi() throws BackingStoreException { | ||
|
||
} | ||
|
||
|
||
protected void flushSpi() throws BackingStoreException { | ||
|
||
} | ||
|
||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...main/java/org/eclipse/paho/client/mqttv3/internal/websocket/HandshakeFailedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2014 IBM Corp. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* Contributors: | ||
* James Sutton - Bug 459142 - WebSocket support for the Java client. | ||
*/ | ||
package org.eclipse.paho.client.mqttv3.internal.websocket; | ||
|
||
public class HandshakeFailedException extends Exception { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
} |
Oops, something went wrong.