Check sip peer channel

How can i check some “sip peer” have a channel?
One method i know this is:
Check list by returned action “ManagerAction_CoreShowChannels”

Do you actually want to know if there is a channel, or do you want to know if it is in use?

second case (want to know if it is in use)

Try with ChanIsAvail()

I must do it on my own application.
Therefore i must use some Asterisk actions

Use AMI Actions and regular expression filter

Excusame, perhaps i could not explain problem.
I want to know at the moment sip has inbound or outbound channel ?
Example sip [1001]

there are many ways to do this, one way is also use the Newchannel event.

Event: Newchannel
Privilege: call,all
Channel: PJSIP/6001-00001819
ChannelState: 4
ChannelStateDesc: Ring
CallerIDNum: 6001
Language: en
Context: internal
Exten: 13052362323
Priority: 1
Uniqueid: 1553458858.6951
Linkedid: 1553458858.6951

You really need to tell us why you think you need to do this. I don’t believe the information is stored in a way in which it can be read forwards. At a low level you would have to enumerate all channels, check whether they had SIP private part, and look to see if that private part was associated with a particular peer.

Note that a peer can have many channels associated with it, Also a SIP dialogue need not have a peer or user associated with it at all.

Also what do you mean by an inbound as against an outbound channel. Do you mean one that starts as UAS, as against UAC. Note that both sides of a call an be incoming or both outgoing, in this sense. Again, knowing your real goals will help avoid such confusion.

1 Like

I didn’t read that part, assuming you want to know if the channel in used is due to an inbound or outbound calls, the most appropriate here is using different context

Ok i explain my idea.
I have some application. In this application i want restrict only one simultaneously dialogue (inbound or outbound).
For it i want restrict “Dial” or “Answer” call if exist channel associated with this peer.
If i catch this i give some information message about this restriction.
Note: I know that Via call-limit option i can restrict. But how can i catch this case for give information message to user?

Group counts are the current preferred way of handling this.

Call limit limits one sided calls as well as two sided ones.

There will always be race conditions in which an incoming connection has started to form but has not created a channel.

1 Like