amiws icon indicating copy to clipboard operation
amiws copied to clipboard

Filter received events based on AMIServerID

Open dppancake opened this issue 2 years ago • 6 comments

Hi,

Would it be possible to filter events based on the AMIServerID when opening a WebSocket? I want to use this as a proxy for multiple systems and I don't want every connected system to receive events from all connected PBX's / AMI Hosts.

Maybe by providing a header with the AMIServerID when opening the WebSocket or sending an action after the connection has been opened?

For example in Python: ws.connect(ws_end_point, header={'AMIServerID': 1}

dppancake avatar Sep 10 '21 12:09 dppancake

Hi, I think, the only way for now would be to filter on client (javascript) side. Just ignore message for 'AMIServerID': 1 in javascript websocket connection.

staskobzar avatar Sep 10 '21 12:09 staskobzar

Hi,

Thanks for the fast reaction.

I already did this, but if possible, I want to prevent to implement this in every system that uses this proxy. Would it be something you could and would implement in amiws?

dppancake avatar Sep 10 '21 12:09 dppancake

I am sorry, but I am not sure I will have a time to work on amiws in near future due to my work load. But I am not sure I do understand how you see that. Filter on IP base? Like when the websocket connection is from IP AAA then filter AMIServerID in 1, 2, or 3 ?

staskobzar avatar Sep 10 '21 13:09 staskobzar

Ah, I understand. Work goes first :)

Well, I don't know the language C, but maybe you could create a unique ID for every connection, so you can seperate them. Create a object with the Unique ID, connection and headers (AMIServerID) / List. Send the message only to object connections which have the Server ID in the object header "AMIServerID" or don't have the "AMIServerID" header defined (receive everything).

The thing is that I could create multiple websockets from the same IP. So only seperating them by IP, wouldn't be that efficient.

Maybe this can help?

This is just a guess, I could be totally wrong ofcourse. Just trying to throw some ideas.

dppancake avatar Sep 10 '21 13:09 dppancake

what you describe is more like rabbitmq queue messages system with topic or direct exchange. Maybe you need better tool for your task, with more powerful features. Not trying to tell you what to do, just an idea )) I have golang library for AMI https://github.com/staskobzar/goami2 For more sophisticated message exchanges I use it with rabbitmq and webstomp or websocket

staskobzar avatar Sep 10 '21 14:09 staskobzar

I will take a look at it. For now I use amiws and filter them client side with the server_id. Thanks for the help.

dppancake avatar Sep 10 '21 14:09 dppancake