MCPcopy Index your code
hub / github.com/rawpython/remi / on_message

Method on_message

remi/server.py:269–301  ·  view source on GitHub ↗
(self, message)

Source from the content-addressed store, hash-verified

267 return True
268
269 def on_message(self, message):
270 global runtimeInstances
271
272 self.send_message(_MSG_ACK)
273
274 with clients[self.session].update_lock:
275 # noinspection PyBroadException
276 try:
277 # saving the websocket in order to update the client
278 if self not in clients[self.session].websockets:
279 clients[self.session].websockets.add(self)
280
281 # parsing messages
282 chunks = message.split('/')
283 self._log.debug('on_message: %s' % chunks[0])
284
285 if len(chunks) > 3: # msgtype,widget,function,params
286 # if this is a callback
287 msg_type = 'callback'
288 if chunks[0] == msg_type:
289 widget_id = chunks[1]
290 function_name = chunks[2]
291 params = message[
292 len(msg_type) + len(widget_id) + len(function_name) + 3:]
293
294 param_dict = parse_parametrs(params)
295
296 callback = get_method_by_name(runtimeInstances[widget_id], function_name)
297 if callback is not None:
298 callback(**param_dict)
299
300 except Exception:
301 self._log.error('error parsing websocket', exc_info=True)
302
303 def close(self, terminate_server=True):
304 try:

Callers 1

read_next_messageMethod · 0.95

Calls 3

send_messageMethod · 0.95
parse_parametrsFunction · 0.85
get_method_by_nameFunction · 0.85

Tested by

no test coverage detected