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

feat: add hook for sending packet from component #2357

Merged
merged 2 commits into from Mar 30, 2018

Conversation

Projects
None yet
2 participants
@Pouriya-Jahanbakhsh
Copy link
Contributor

Pouriya-Jahanbakhsh commented Mar 30, 2018

Hi. This PR added new hook component_send_packet for sending packet from components. Callback function must accept one argument {Pkt, ComponentState} and should yield drop or {NewPkt, NewComponentState}.

feat: add hook for sending packet from component
New hook 'component_send_packet' added.
Callback function must accept one argument {Pkt, ComponentState} and should yield 'drop' or {NewPkt, NewComponentState}.
@Pouriya-Jahanbakhsh

This comment has been minimized.

Copy link
Contributor

Pouriya-Jahanbakhsh commented Mar 30, 2018

Tests have been passed for my fork.

@zinid

This comment has been minimized.

Copy link
Member

zinid commented Mar 30, 2018

I think this hook should be global, i.e. without Server, just like component_connected hook.

@Pouriya-Jahanbakhsh

This comment has been minimized.

Copy link
Contributor

Pouriya-Jahanbakhsh commented Mar 30, 2018

Then should be:

        {Pkt2, State2} = ejabberd_hooks:run_fold(component_send_packet, {Pkt, State}, []),
        case Pkt2 of
            drop ->
                ok;
            _ ->
                ejabberd_router:route(Pkt2)
		end,
        State2;

Am i right? if yes then i'll edit it.

@Pouriya-Jahanbakhsh

This comment has been minimized.

Copy link
Contributor

Pouriya-Jahanbakhsh commented Mar 30, 2018

Is there hooks documentation in repo? I can't find it for update !

@zinid

This comment has been minimized.

Copy link
Member

zinid commented Mar 30, 2018

Am i right? if yes then i'll edit it

Yes, you're right.

Is there hooks documentation in repo? I can't find it for update !

No, there are not such repos.

@zinid zinid merged commit 0041a11 into processone:master Mar 30, 2018

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@Pouriya-Jahanbakhsh Pouriya-Jahanbakhsh deleted the Pouriya-Jahanbakhsh:component-send-packet-hook branch Apr 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment