Skip to content
Snippets Groups Projects
Commit 391a0a92 authored by Stefan Glaser's avatar Stefan Glaser
Browse files

Simplified TransportHints class.

* Replaced internal map with simple boolean.
* Fixed initialization bug.
* Fixed code style.
parent 7ae94f60
Branches
No related tags found
No related merge requests found
package org.ros.node.topic;
import java.util.Map;
import org.ros.internal.transport.ConnectionHeaderFields;
import org.ros.node.ConnectedNode;
import com.google.common.collect.Maps;
/**
* Provides a way of specifying network transport hints to
* {@link ConnectedNode#newSubscriber(String, String)} and
* {@link ConnectedNode#newSubscriber(org.ros.namespace.GraphName, String)}.
* {@link ConnectedNode#newSubscriber(org.ros.namespace.GraphName, String, TransportHints)} and
* {@link ConnectedNode#newSubscriber(String, String, TransportHints)}.
*
* @author stefan.glaser@hs-offenburg.de (Stefan Glaser)
*/
public class TransportHints {
Map<String, String> options;
private boolean tcpNoDelay;
public TransportHints() {
this.options = Maps.newConcurrentMap();
this(false);
}
public TransportHints(boolean tcpNoDelay) {
tcpNoDelay(tcpNoDelay);
this.tcpNoDelay = tcpNoDelay;
}
public TransportHints tcpNoDelay(boolean nodelay) {
options.put(ConnectionHeaderFields.TCP_NODELAY, nodelay ? "1" : "0");
public TransportHints tcpNoDelay(boolean tcpNoDelay) {
this.tcpNoDelay = tcpNoDelay;
return this;
}
public boolean getTcpNoDelay() {
return "1".equals(options.get(ConnectionHeaderFields.TCP_NODELAY));
}
public Map<String, String> getOptions() {
return options;
return tcpNoDelay;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment