librelist archives

« back to archive

Send message via javascript

Send message via javascript

From:
giorgio paolucci
Date:
2014-10-07 @ 13:35
Hello,
is there any way to send a message through converse.js in a non 
interactive way?
I would like to hook a webtrc  base video chat to converse.js so that 
when a user clicks on the phone icon (via the subscription of the event 
callButtonClicked) an external URL would be launched and a text message 
to the receiver containing the peerId should be sent.

Subscribing the "message" event, the receiver could get the peerId and 
launch the videochat application to setup the call.

Any chance to accomplish that?

Best regards.

Giorgio Paolucci


-- 

      Ing. Giorgio Paolucci
      Universita' di Padova
      Centro Servizi Informatici di Ateneo
      Responsabile Infrastrutture,
      Networking e Sicurezza
      Tel.+39-049-8273711

-- 

Re: [conversejs] Send message via javascript

From:
Jc Brand
Date:
2014-10-07 @ 14:18
On Tue, Oct 07, 2014 at 03:35:49PM +0200, giorgio paolucci wrote:
> Hello,
> is there any way to send a message through converse.js in a non 
> interactive way?
> I would like to hook a webtrc  base video chat to converse.js so that 
> when a user clicks on the phone icon (via the subscription of the event 
> callButtonClicked) an external URL would be launched and a text message 
> to the receiver containing the peerId should be sent.
> 
> Subscribing the "message" event, the receiver could get the peerId and 
> launch the videochat application to setup the call.
> 
> Any chance to accomplish that?

Sending a message programmatically is something that's been asked for before
and is mentioned in the API ticket:
https://github.com/jcbrand/converse.js/issues/46

However, there isn't yet such an API method.

send message via javascript

From:
Beginner Ti
Date:
2015-05-06 @ 22:54
Hi JC,

I saw that this has been asked before and at the time of 2014/10 there are
still no such functions. I looked at the API and didn't see that either.
Not sure if it already exists somewhere?

Thanks,
Rui

Re: [conversejs] send message via javascript

From:
Safia Yonker
Date:
2015-05-07 @ 04:49
I am curious about this as well.  I have had a similar need and found a 
solution but it is something of a hack. 
 
first I make sure the contact’s message box is open (using the exposed API)

The next part is the hack:
the converse.initialize function accepts a callback as its second 
argument…I provide a callback and within that function grab a reference to
“this” which is (in this context) the full converse object (not the 
limited one that is exposed to the global scope)

using my reference to the full converse object I invoke the send method on
the chatbox I made sure was opened in my first step.

I suspect there is a better way but this does work.

I am not on my dev machine but if you are interested in the details (and 
no one has offered a better solution) send an email and I will provide the
details.

Safia


> On May 6, 2015, at 4:54 PM, Beginner TI <ruiwang.sz@gmail.com> wrote:
> 
> Hi JC,
> 
> I saw that this has been asked before and at the time of 2014/10 there 
are still no such functions. I looked at the API and didn't see that 
either. Not sure if it already exists somewhere?
> 
> Thanks,
> Rui

Re: [conversejs] send message via javascript

From:
Beginner Ti
Date:
2015-05-07 @ 07:05
thanks!

btw, I found that I could do something like:

var Room = converse.env.Strophe.xmlElement("body", "my test message");
 var tmsg = converse.env.$msg({from: from, to: to, type:
'chat'}).cnode(Room);
 converse.connection.send(tmsg.tree());

this works. now, how did you make it work? :-)

cheers,
Rui

On Wed, May 6, 2015 at 9:49 PM, Safia Yonker <safia@aljex.com> wrote:

> I am curious about this as well.  I have had a similar need and found a
> solution but it is something of a hack.
>
> first I make sure the contact’s message box is open (using the exposed API)
>
> The next part is the hack:
> the converse.initialize function accepts a callback as its second
> argument…I provide a callback and within that function grab a reference to
> “this” which is (in this context) the full converse object (not the limited
> one that is exposed to the global scope)
>
> using my reference to the full converse object I invoke the send method on
> the chatbox I made sure was opened in my first step.
>
> I suspect there is a better way but this does work.
>
> I am not on my dev machine but if you are interested in the details (and
> no one has offered a better solution) send an email and I will provide the
> details.
>
> Safia
>
>
> > On May 6, 2015, at 4:54 PM, Beginner TI <ruiwang.sz@gmail.com> wrote:
> >
> > Hi JC,
> >
> > I saw that this has been asked before and at the time of 2014/10 there
> are still no such functions. I looked at the API and didn't see that
> either. Not sure if it already exists somewhere?
> >
> > Thanks,
> > Rui
>
>