Skip to content

Commit

Permalink
Merge pull request RobotWebTools#250 from sevenbitbyte/SESSION_STATUS
Browse files Browse the repository at this point in the history
Support status level messages
  • Loading branch information
jihoonl authored Mar 1, 2017
2 parents ac61584 + 03db06e commit e899b6d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
26 changes: 24 additions & 2 deletions build/roslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,22 @@ Ros.prototype.callOnConnection = function(message) {
}
};

/**
* Sends a set_level request to the server
*
* @param level - Status level (none, error, warning, info)
* @param id - Optional: Operation ID to change status level on
*/
Ros.prototype.setStatusLevel = function(level, id){
var levelMsg = {
op: 'set_level',
level: level,
id: id
};

this.callOnConnection(levelMsg);
};

/**
* Retrieves Action Servers in ROS as an array of string
*
Expand Down Expand Up @@ -1875,7 +1891,7 @@ Ros.prototype.getNodes = function(callback, failedCallback) {
};

/**
* Retrieves list subscribed topics, publishing topics and services of a specific node
* Retrieves list subscribed topics, publishing topics and services of a specific node
*
* @param node name of the node:
* @param callback - function with params:
Expand Down Expand Up @@ -2269,7 +2285,7 @@ if(typeof bson !== 'undefined'){
* Events listeners for a WebSocket or TCP socket to a JavaScript
* ROS Client. Sets up Messages for a given topic to trigger an
* event on the ROS client.
*
*
* @namespace SocketAdapter
* @private
*/
Expand All @@ -2281,6 +2297,12 @@ function SocketAdapter(client) {
client.emit(message.id, message);
} else if (message.op === 'call_service') {
client.emit(message.service, message);
} else if(message.op === 'status'){
if(message.id){
client.emit('status:'+message.id, message);
} else {
client.emit('status', message);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions build/roslib.min.js

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion src/core/Ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ Ros.prototype.callOnConnection = function(message) {
}
};

/**
* Sends a set_level request to the server
*
* @param level - Status level (none, error, warning, info)
* @param id - Optional: Operation ID to change status level on
*/
Ros.prototype.setStatusLevel = function(level, id){
var levelMsg = {
op: 'set_level',
level: level,
id: id
};

this.callOnConnection(levelMsg);
};

/**
* Retrieves Action Servers in ROS as an array of string
*
Expand Down Expand Up @@ -386,7 +402,7 @@ Ros.prototype.getNodes = function(callback, failedCallback) {
};

/**
* Retrieves list subscribed topics, publishing topics and services of a specific node
* Retrieves list subscribed topics, publishing topics and services of a specific node
*
* @param node name of the node:
* @param callback - function with params:
Expand Down
8 changes: 7 additions & 1 deletion src/core/SocketAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(typeof bson !== 'undefined'){
* Events listeners for a WebSocket or TCP socket to a JavaScript
* ROS Client. Sets up Messages for a given topic to trigger an
* event on the ROS client.
*
*
* @namespace SocketAdapter
* @private
*/
Expand All @@ -31,6 +31,12 @@ function SocketAdapter(client) {
client.emit(message.id, message);
} else if (message.op === 'call_service') {
client.emit(message.service, message);
} else if(message.op === 'status'){
if(message.id){
client.emit('status:'+message.id, message);
} else {
client.emit('status', message);
}
}
}

Expand Down

0 comments on commit e899b6d

Please sign in to comment.