Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix websocket handshake for ROS Noetic #31

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>edu.wpi.rail</groupId>
<artifactId>jrosbridge</artifactId>
<version>0.2.2-SNAPSHOT</version>
<version>0.2.3</version>

<properties>
<java.version>1.8</java.version>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/edu/wpi/rail/jrosbridge/ClientConfigurator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package edu.wpi.rail.jrosbridge;

import java.util.List;
import java.util.Map;

import javax.websocket.ClientEndpoint;
import javax.websocket.ClientEndpointConfig;

@ClientEndpoint
public class ClientConfigurator extends ClientEndpointConfig.Configurator{

@Override
public void beforeRequest(Map<String, List<String>> headers) {

super.beforeRequest(headers);
}

}
11 changes: 8 additions & 3 deletions src/main/java/edu/wpi/rail/jrosbridge/Ros.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;

import edu.wpi.rail.jrosbridge.callback.CallServiceCallback;
import edu.wpi.rail.jrosbridge.services.ServiceRequest;
Expand All @@ -41,7 +42,8 @@
* @author Russell Toris - [email protected]
* @version April 1, 2014
*/
@ClientEndpoint
@ClientEndpoint(
configurator = ClientConfigurator.class)
public class Ros {

/**
Expand Down Expand Up @@ -201,8 +203,10 @@ public boolean connect() {
try {
// create a WebSocket connection here
URI uri = new URI(this.getURL());
ContainerProvider.getWebSocketContainer()
.connectToServer(this, uri);

WebSocketContainer wsc = ContainerProvider.getWebSocketContainer();
wsc.connectToServer(this, uri);

return true;
} catch (DeploymentException | URISyntaxException | IOException e) {
// failed connection, return false
Expand Down Expand Up @@ -537,4 +541,5 @@ public void deregisterCallServiceCallback(String serviceName) {
// remove the callback
callServiceCallbacks.remove(serviceName);
}

}