Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multi-reply handlers #92

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

real-alexei
Copy link

@sidorares Now it's possible to keep handlers as needed. For example, to track input events with a Record extension (e.g. EnableContext):

ext.EnableContext = function(ctx, cb) {
  X.seq_num++;
  X.pack_stream.pack('CCSL', [ext.majorOpcode, 5, 2, ctx]);
  X.replies[X.seq_num] = [
    handler,
    cb,
    true // multiReply
  ];
  X.pack_stream.flush();
}

@sidorares
Copy link
Owner

so the callback decides when last packet arrives? Looks wrong to me, should be in the handler code

@real-alexei
Copy link
Author

Introduced unsubscribe callback to work with core request templates.

@real-alexei
Copy link
Author

Should I rename the callback to removeHandler?

@sidorares
Copy link
Owner

Hey @aselivanov sorry this was silent for months.
Would like to merge this but really need to add some tests

@santigimeno maybe you could assist?

if (client.options.debug)
delete client.seq2stack[seq_num];
delete client.replies[seq_num];
if (client.options.debug)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation

@santigimeno
Copy link
Collaborator

@sidorares sure
@aselivanov yes, some tests are needed. Let me know if you need help with them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants