staskobzar / amiws

Asterisk Management Interface (AMI) to Web-socket proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

start command to send data

Newassistent opened this issue · comments

Hi, you can have the websocket server (amiws) send data to the client only after receiving a command from the Javascript script.
For example "ws.send ('start')"?
if yes, how can i do?

Hello,
You can send commands to Asterisk whenever you want.
it is AMI proxy, so you need to send AMI commands.
Here is an example: https://github.com/staskobzar/amiws_queue/blob/master/src/store/mutations.js#L107

thanks for the fast reply.
I think I wasn't very clear...
I would like to communicate with amiws proxy from browser (script javascript) and not from/to the Asterisk side.
I would like to send a string from browser to amiws for enable the start of the transmission of json strings to the browser.

Yes, you can send commands from browser with javascript.
How to do this is your choice of implementation.

ws.send(JSON.stringify({
      Action: 'QueueAdd',
      AMIServerID: queue.sid,
      Queue: queue.name,
      Interface: member.interface,
      Penalty: member.penalty,
      Paused: member.paused,
      MemberName: member.name
    }))

Thanks, I know this way to communicate with websocket, but I would like to add in the Amiws source files the possibility of NOT immediately sending all the json data to the browser, but after the handshake, wait my input to start the communication . Which source file or function should I work on?

May you can just implement delay to connect and send in your javascript? I am sorry, but I probably do not understand what you are trying to do. Javascript is all under your control. You can simply connect amiws via websocket when your data is ready.

ok, i will try the best solution thanks.
Another question: I need to read the URI content in the amiws_lib.c source file, in the ami_ev_handler function.
Can you help me, sorry i don't know C language very well.
thanks a lot.

I was using mongoose library for the networking (https://github.com/cesanta/mongoose/)
you can see for helper function there. There are plenty of other C libraries which can help parse URI.