update to grpc edit_node to allow editing icon and broadcasting a node update for all to listen to a change
This commit is contained in:
parent
74e15d9c9d
commit
5d5ffb70c2
3 changed files with 9 additions and 4 deletions
|
@ -326,19 +326,20 @@ class CoreGrpcClient(object):
|
|||
request = core_pb2.GetNodeRequest(session_id=session_id, node_id=node_id)
|
||||
return self.stub.GetNode(request)
|
||||
|
||||
def edit_node(self, session_id, node_id, position):
|
||||
def edit_node(self, session_id, node_id, position, icon=None):
|
||||
"""
|
||||
Edit a node, currently only changes position.
|
||||
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param core_pb2.Position position: position to set node to
|
||||
:param str icon: path to icon for gui to use for node
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.EditNodeResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.EditNodeRequest(
|
||||
session_id=session_id, node_id=node_id, position=position
|
||||
session_id=session_id, node_id=node_id, position=position, icon=icon
|
||||
)
|
||||
return self.stub.EditNode(request)
|
||||
|
||||
|
|
|
@ -842,8 +842,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
"""
|
||||
logging.debug("edit node: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
node_id = request.node_id
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
node_options = NodeOptions()
|
||||
node_options.icon = request.icon
|
||||
x = request.position.x
|
||||
y = request.position.y
|
||||
node_options.set_position(x, y)
|
||||
|
@ -853,7 +854,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
node_options.set_location(lat, lon, alt)
|
||||
result = True
|
||||
try:
|
||||
session.update_node(node_id, node_options)
|
||||
session.update_node(node.id, node_options)
|
||||
node_data = node.data(0)
|
||||
session.broadcast_node(node_data)
|
||||
except CoreError:
|
||||
result = False
|
||||
return core_pb2.EditNodeResponse(result=result)
|
||||
|
|
|
@ -316,6 +316,7 @@ message EditNodeRequest {
|
|||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
Position position = 3;
|
||||
string icon = 4;
|
||||
}
|
||||
|
||||
message EditNodeResponse {
|
||||
|
|
Loading…
Reference in a new issue