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

start command to send data #16

Open
Newassistent opened this issue Jun 11, 2020 · 8 comments
Open

start command to send data #16

Newassistent opened this issue Jun 11, 2020 · 8 comments

Comments

@Newassistent
Copy link

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?

@staskobzar
Copy link
Owner

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

@Newassistent
Copy link
Author

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.

@staskobzar
Copy link
Owner

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
    }))

@staskobzar
Copy link
Owner

Here is example project: https://github.com/staskobzar/amiws_queue

@Newassistent
Copy link
Author

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?

@staskobzar
Copy link
Owner

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.

@Newassistent
Copy link
Author

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.

@staskobzar
Copy link
Owner

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.

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

No branches or pull requests

2 participants