[ejabberd] exmpp and BOSH

Ian Wilkinson the.ian.wilkinson at googlemail.com
Wed Dec 9 23:17:06 MSK 2009


Hi Pablo,

This may be huge dumbness on my part...from my reading of

http://metajack.im/2008/10/03/getting-attached-to-strophe/

it suggests you can establish the BOSH connection, and then make the sid and
rid
available as session state to allow their use in calling

connection.attach(BOSH_JID, BOSH_SID, BOSH_RID, onConnect);

from within the JavaScript client. The desire, here, to not expose the
user credentials.

Assuming this was a sound approach, I made the following changes:

exmpp_session.erl

%% @doc Obtain the Request ID for this BOSH connection.
-spec(get_bosh_rid(Session::pid()) -> {ok, integer()}).
get_bosh_rid(Session) ->
    gen_fsm:sync_send_all_state_event(Session, get_bosh_rid).

...

handle_sync_event(get_bosh_rid, _From, StateName, #state{connection_ref =
ConnRef} = State) ->
    Reply = exmpp_bosh:get_rid(ConnRef),
    {reply, Reply, StateName, State}.


And exmpp_bosh.erl

-spec(get_rid(Pid::pid()) -> {ok, integer()}).
get_rid(Pid) ->
    gen_server:call(Pid, get_rid).

...

handle_call(get_rid, _From, #state{rid = Rid} = State) ->
    {reply, {ok, Rid}, State};


I'm prepared for withering comment...

many thanks,
ian


On Wed, Dec 9, 2009 at 7:07 PM, Pablo Polvorin <
pablo.polvorin at process-one.net> wrote:

> Hi Ian,
> I'm not sure to understand what is your intended scenario. Why do you
> need exmpp_bosh if your final
> goal is to use strophe?.
>
> Anyway, you are right,  currently there is no way to obtain the
> initial request ID after calling
> exmpp_session:connect_BOSH/4.
> Why do you need it?, it is only the initial request ID, or the last
> request ID sent?.  It could be added to the exmpp API if there is a
> need for this.
>
>
>
> 2009/12/7 Ian Wilkinson <the.ian.wilkinson at googlemail.com>:
> > Hi,
> > I'm looking to adopt Strophe as client-side library, and following the
> > reading
> > of http://metajack.im/2008/10/03/getting-attached-to-strophe/, I'm
> > attempting
> > to discover how to obtain the Request ID from the session created with
> > exmpp_session:connect_BOSH/4.
> > There is strong comment that exmpp_bosh should not be called by client
> > developers (I had noticed exmpp_bosh:reset_parser/1 gave visibility of
> the
> > rid).
> > So, for the moment I am struggling to discover the correct method for
> > obtaining the Request ID I can then use with Strophe.
> > Any help very welcome (and it may be I am betraying ignorance on XMPP
> > usage).
> > many thanks,
> > ian
> >
> >
> > _______________________________________________
> > ejabberd mailing list
> > ejabberd at jabber.ru
> > http://lists.jabber.ru/mailman/listinfo/ejabberd
> >
> >
>
>
>
> --
> Pablo Polvorin
> ProcessOne
> _______________________________________________
> ejabberd mailing list
> ejabberd at jabber.ru
> http://lists.jabber.ru/mailman/listinfo/ejabberd
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20091209/f2be155a/attachment.html>


More information about the ejabberd mailing list