Show More
@@ -1165,7 +1165,7 b' class Hub(SessionFactory):' | |||
|
1165 | 1165 | msg = self.session.msg(header['msg_type']) |
|
1166 | 1166 | msg['content'] = rec['content'] |
|
1167 | 1167 | msg['header'] = header |
|
1168 | msg['msg_id'] = rec['msg_id'] | |
|
1168 | msg['header']['msg_id'] = rec['msg_id'] | |
|
1169 | 1169 | self.session.send(self.resubmit, msg, buffers=rec['buffers']) |
|
1170 | 1170 | |
|
1171 | 1171 | finish(dict(status='ok')) |
@@ -350,15 +350,15 b' class Session(Configurable):' | |||
|
350 | 350 | def msg_header(self, msg_type): |
|
351 | 351 | return msg_header(self.msg_id, msg_type, self.username, self.session) |
|
352 | 352 | |
|
353 | def msg(self, msg_type, content=None, parent=None, subheader=None): | |
|
353 | def msg(self, msg_type, content=None, parent=None, subheader=None, header=None): | |
|
354 | 354 | """Return the nested message dict. |
|
355 | 355 | |
|
356 | 356 | This format is different from what is sent over the wire. The |
|
357 |
se |
|
|
358 |
format, which |
|
|
357 | serialize/unserialize methods converts this nested message dict to the wire | |
|
358 | format, which is a list of message parts. | |
|
359 | 359 | """ |
|
360 | 360 | msg = {} |
|
361 | msg['header'] = self.msg_header(msg_type) | |
|
361 | msg['header'] = self.msg_header(msg_type) if header is None else header | |
|
362 | 362 | msg['parent_header'] = {} if parent is None else extract_header(parent) |
|
363 | 363 | msg['content'] = {} if content is None else content |
|
364 | 364 | sub = {} if subheader is None else subheader |
@@ -436,8 +436,8 b' class Session(Configurable):' | |||
|
436 | 436 | |
|
437 | 437 | return to_send |
|
438 | 438 | |
|
439 |
def send(self, stream, msg_or_type, content=None, parent=None, ident=None |
|
|
440 |
|
|
|
439 | def send(self, stream, msg_or_type, content=None, parent=None, ident=None | |
|
440 | buffers=None, subheader=None, track=False, header=None): | |
|
441 | 441 | """Build and send a message via stream or socket. |
|
442 | 442 | |
|
443 | 443 | The message format used by this function internally is as follows: |
@@ -445,37 +445,41 b' class Session(Configurable):' | |||
|
445 | 445 | [ident1,ident2,...,DELIM,HMAC,p_header,p_parent,p_content, |
|
446 | 446 | buffer1,buffer2,...] |
|
447 | 447 | |
|
448 |
The se |
|
|
448 | The serialize/unserialize methods convert the nested message dict into this | |
|
449 | 449 | format. |
|
450 | 450 | |
|
451 | 451 | Parameters |
|
452 | 452 | ---------- |
|
453 | 453 | |
|
454 | 454 | stream : zmq.Socket or ZMQStream |
|
455 |
|
|
|
455 | The socket-like object used to send the data. | |
|
456 | 456 | msg_or_type : str or Message/dict |
|
457 | 457 | Normally, msg_or_type will be a msg_type unless a message is being |
|
458 | 458 | sent more than once. |
|
459 | 459 | |
|
460 | 460 | content : dict or None |
|
461 |
|
|
|
461 | The content of the message (ignored if msg_or_type is a message). | |
|
462 | header : dict or None | |
|
463 | The header dict for the message (ignores if msg_to_type is a message). | |
|
462 | 464 | parent : Message or dict or None |
|
463 |
|
|
|
465 | The parent or parent header describing the parent of this message | |
|
466 | (ignored if msg_or_type is a message). | |
|
464 | 467 | ident : bytes or list of bytes |
|
465 |
|
|
|
468 | The zmq.IDENTITY routing path. | |
|
466 | 469 | subheader : dict or None |
|
467 |
|
|
|
470 | Extra header keys for this message's header (ignored if msg_or_type | |
|
471 | is a message). | |
|
468 | 472 | buffers : list or None |
|
469 |
|
|
|
473 | The already-serialized buffers to be appended to the message. | |
|
470 | 474 | track : bool |
|
471 |
|
|
|
472 |
|
|
|
475 | Whether to track. Only for use with Sockets, because ZMQStream | |
|
476 | objects cannot track messages. | |
|
473 | 477 | |
|
474 | 478 | Returns |
|
475 | 479 | ------- |
|
476 |
msg : |
|
|
477 |
|
|
|
478 |
(msg,tracker) : ( |
|
|
480 | msg : dict | |
|
481 | The constructed message. | |
|
482 | (msg,tracker) : (dict, MessageTracker) | |
|
479 | 483 | if track=True, then a 2-tuple will be returned, |
|
480 | 484 | the first element being the constructed |
|
481 | 485 | message, and the second being the MessageTracker |
@@ -488,12 +492,13 b' class Session(Configurable):' | |||
|
488 | 492 | raise TypeError("ZMQStream cannot track messages") |
|
489 | 493 | |
|
490 | 494 | if isinstance(msg_or_type, (Message, dict)): |
|
491 |
# |
|
|
492 |
# |
|
|
495 | # We got a Message or message dict, not a msg_type so don't | |
|
496 | # build a new Message. | |
|
493 | 497 | msg = msg_or_type |
|
494 | 498 | else: |
|
495 |
msg = self.msg(msg_or_type, content, parent, |
|
|
496 | ||
|
499 | msg = self.msg(msg_or_type, content=content, parent=parent, | |
|
500 | subheader=subheader, header=header) | |
|
501 | ||
|
497 | 502 | buffers = [] if buffers is None else buffers |
|
498 | 503 | to_send = self.serialize(msg, ident) |
|
499 | 504 | flag = 0 |
@@ -523,7 +528,7 b' class Session(Configurable):' | |||
|
523 | 528 | msg['tracker'] = tracker |
|
524 | 529 | |
|
525 | 530 | return msg |
|
526 | ||
|
531 | ||
|
527 | 532 | def send_raw(self, stream, msg_list, flags=0, copy=True, ident=None): |
|
528 | 533 | """Send a raw message via ident path. |
|
529 | 534 | |
@@ -545,7 +550,7 b' class Session(Configurable):' | |||
|
545 | 550 | ident = [ident] |
|
546 | 551 | if ident is not None: |
|
547 | 552 | to_send.extend(ident) |
|
548 | ||
|
553 | ||
|
549 | 554 | to_send.append(DELIM) |
|
550 | 555 | to_send.append(self.sign(msg_list)) |
|
551 | 556 | to_send.extend(msg_list) |
General Comments 0
You need to be logged in to leave comments.
Login now