Get all open connections in Swift - networking

Is it possible to receive a list of all established connections in Swift like when using the "lsof" command?
I just saw that system calls (using Process) are not allowed in the Sandbox (which makes sense...).

Related

Asterisk IP-PBX: API to set up and tear down a call between two extensions

I have a working system that controls a Cisco CUCM IP-PBX to set up and tear down a call between two parties A and B; it makes use of Java's JTAPI to:
make A call B
make B answer (pick up)
(wait for a few seconds)
make either A or B drop the call
Now I want to do the same with an Asterisk PBX (version 13.17.0). From what I have gathered, Asterisks JTAPI implementation doesn't work for recent Asterisks; the latest version that I can find, dates from 2006 and it seems to try and send AMI commands to which Asterisk replies something along the lines of "no such command" - I'm guessing the AMI syntax has changed over the years.
What I'm using now is a library called asterisk-java and more specifically, its AMI support. I'm sending an OriginateAction and the net effect is that:
Asterisk calls A
I have to pick up A's phone manually
A calls B
I have to pick up B's phone manually
finally a call is established between A and B
So instead of a fully automated process like in the Cisco case, I have to do manual work and I can't seem to find an API to just set up a call between A and B and having it drop after a couple of seconds.
Questions: is the AMI the correct API for my use case or is there a better alternative? And what API calls do I have to make to establish and drop a call?
Thanks,
Jan
Does this answered question help with establishing a call without picking up:
Originate a call with Asterisk - without the originating extension ringing
To have a channel drop a call, using AMI, you can use 'BridgeKick' to boot a channel, or 'BridgeDestroy' to cause each channel to 'BridgeLeave':
https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerAction_BridgeKick

Freepbx data integration with custom CRM

NET experts,
I have a scenario where a 4-port PSTN card is installed in a server and I have installed Freebpx on that server as per suggestion by someone. When a call comes on any of the PSTN line, it is forwarded to one of the operators on his hard phone.
Each operator is also having a computer screen at his table, powered by an individual CPU. This runs our CRM software to be handled by operator. When a call arrives to an operator hard phone, say operator 2, we want that the Caller number should also be displayed in the CRM software. Based on this caller number, operator can enter some information related to the Caller and save it in database via our CRM software. Also, when operator disconnect the call, we should receive call stop time for statistics later on.
Thus, we need caller number and call start time when a call is picked by an operator on his hard phone. and then we need call end time when a call is finished.
Can someone help us how we can achieve this? Do we have to capture the SIP packets and parse them or their is some other way to do so? Our CRM database is totally separate from the Freepbx and resides on another server.
If you want to get these events realtime, you should look at AMI (Asterisk Manager Interface - port 5038 TCP by default) and it's configuration manager.conf (note: FreePBX uses the, see manager_custom.conf).
If you want the archived version, you should set up a database server, and point the CDR (Call Detail Records) module to it. PostgreSQL or MySQL/MariaDB works just fine. Asterisk will simply ignore additional fields in the CDR as long as they can be NULL or has a DEFAULT value. This can be used to store custom data.

Is there any possibility for one rserve's client to share workspace with another?

I'd like replace RExcel with the Excelsi-R. Excelsi-R talks R via RServe, and RServe has this feature, that makes each client work in independent workspaces.
What I want is to actually share a single workspace between at least 2 simultaneously connected clients. One client would be run by Excelsi-R, and another by manually launched interactive R Session. That would allow me to interface with the Excelsi-R session in traditional way (say, in RStudio).
I don't need asynchronous computation; I'm perfectly happy if Excelsi-R would have to wait, until a command issued by the other connection finishes, and vice versa; just like in the RExcel "foreground mode".
Is it possible?
Not currently, since each process has exactly one connection. There are a few hacks - such as you can "switch" sessions by starting a listener for another connection in an existing session - but that may be a bit too limited.
That said, it is technically possible (Rserve support looping over multiple connections - it is used in RCloud to support two separate processes on one connection) - the challenge is how to link two independent connections to a single process. The rsio communication was added in Rserve 1.8 specifically to allow the passing of descriptors between Rserve instances, but it was not used so far. If there is interest in that kind of functionality, I can see how it could be added.

Asterisk AMI Atxfer on explicitely bridged channels

I'm trying to complete software which does all call logic via AMI on it's own using Asterisk only as interface to VOIP, SIP/GSM. Almost everything works great, but...:
Here is my scenario:
- incoming call is forwarded to announcement and then to MOH forever
- my app decides which extensions to dial (7777) using AMI Action: Originate
- once somebody picks up on extension, his/her channel (SIP/306-xxxxx for example) is bridged with waiting call's channel using AMI Action: Bridge
Until this point everything is working fine, both connected parties can hear each other, recording on demand works. All is fine.
Now I'm trying to make assisted transfer to another extension (Atxfer) using AMI on one of the bridged channels. And it doesn't work. I got couple of ami events about DTMF's on a channel (audio is muted while they are played). Every DTMF digit couses quick Bridge:unlink and Bridge:link event on AMI.
I tried to change dtmfmode, upgrade from asterisk 1.8 to 11 (asterisk now) and it always was the same.
While having this problems with Atxfer blind transfer on those channels works (using AMI Action: Redirect).
full log shows nothing something like this:
[2013-11-11 20:24:57] DEBUG[9457]: features.c:3740 feature_interpret: Feature interpret: chan=SIP/306-00000017, peer=SIP/GTS-00000016, code=*2, sense=1, features=0, dynamic=apprecord#apprecord
I recommend you read some asterisk book for beginner like ORelly's "Asterisk the future of telephony".
In you case correct solution is use asterisk Dial command for first channel instead of second call creation.
It is not clear how you do transfer using AMI. If you want do it via ami(which is VERY bad way), you have do something like following
On transfer request(digit) unbridge channels. Better put it in AsyncAGI after that.
Collect digits where to transfer using Read command
Transfer to new destination
If fail bridge again
NOTE: You resulting application will be really buggy and not scalable. AMI interface is not designed to do such things and work very bad when you have alot of actions and channels running on same box. So you have test your app under hi concurrent load to ensure it work(or more likly not work).

J2ME: Multiple HttpConnection fail on device (Nokia C2-O3)

I try to create Asynchronous(non-blocking) request in my J2me application.
I write code as per this tutorial: Ajax-like Asynchronous SOA Calls with Java ME.
Code run successfully on emulator on Netbeans.
But when app deploy and device it fails on multiple connection.
When two connection open. then first connection tread kill and execute second only.
This problem only on device. It works fine on PC
According to this article http://developers.sun.com/mobility/midp/articles/mmapioverview/index.html "Note also that MIDP limits the number of HTTP connections open simultaneously to four.", but your device seems to only allow one connection.
In this case you should create a queue and execute one thread at a time.

Resources