Detect whether an extension is connected or not

david90

Bronze Partner
Advanced Certified
Joined
Nov 2, 2012
Messages
40
Reaction score
9
Hello,

In a CFD, I route my calls according to the status of the extension (available or not, on call or not).
Unfortunately, when the extension is completely disconnected, the status remains on "Available" and "Not on call".
My CFD then tries to connect the call... Without success, as the extension is disconnected.

Is there any way of detecting whether the extension is connected or not? I haven't found anything in the documentation about this...

Thanks in advance for your feedback!
David

Translated with Deepl

System :
3CX Version 20.0 Update 2 (Build 715 Release)
Debian 12
CFD Version : 18.5.8
 
You can use a C# script to know if the extension "100" is registered, for example:
return ((Extension)PhoneSystem.Root.GetDNByNumber("100")).IsRegistered;
 
You can use a C# script to know if the extension "100" is registered, for example:
return ((Extension)PhoneSystem.Root.GetDNByNumber("100")).IsRegistered;

This will return either true or false.

We can also have some fun by adding support for the scenario where the extension doesn't exist or isn't a user extension, in which case we return "false". :p

Code:
return (PhoneSystem.Root.GetDNByNumber("100") is Extension ext) ? ext.IsRegistered : false;

What? Mistakes happen, it's better to handle this scenario while we're at it, lol.xD
I couldn’t resist outbidding Ernesto, I have a reputation to uphold hahahahahaha! :cool:
 
This will return either true or false.

We can also have some fun by adding support for the scenario where the extension doesn't exist or isn't a user extension, in which case we return "false". :p

Code:
return (PhoneSystem.Root.GetDNByNumber("100") is Extension ext) ? ext.IsRegistered : false;

What? Mistakes happen, it's better to handle this scenario while we're at it, lol.xD
I couldn’t resist outbidding Ernesto, I have a reputation to uphold hahahahahaha! :cool:
Thank you very much for your reply, and also to @edossantos_sipcaller ! It works perfectly!
I've never done C# before, but it integrates really easily into the CFD! One function, one variable for the extension to check, and it's all good!
 
Thank you very much for your reply, and also to @edossantos_sipcaller ! It works perfectly!
I've never done C# before, but it integrates really easily into the CFD! One function, one variable for the extension to check, and it's all good!

I'm glad you liked it! If you have more requests like this, feel free to tag me in your posts.

Read more about the CallControlAPI here:
https://www.3cx.com/blog/releases/v20-call-control-api/

If I can respond quickly, I'd be happy to help, but we have several knowledgeable people here. I've taught Ernesto ( @edossantos_sipcaller ) the basics of the CallControlAPI, and he's starting to get quite good at it :rolleyes: .

You are at the beginning of the infinite capabilities of Call Processing Script. :cool:
 
Hahahaha @Guillaume Bourgeois! Try to beat this one:
return ((Extension)PhoneSystem.Root.GetDNByNumber("100"))?.IsRegistered ?? false;
 
Hahahaha @Guillaume Bourgeois! Try to beat this one:
return ((Extension)PhoneSystem.Root.GetDNByNumber("100"))?.IsRegistered ?? false;

xD

Code:
 return ((Extension)PhoneSystem.Root.GetDNByNumber("100")) is Extension ext ? (ext.Enabled ? ext.IsRegistered : false) : false;

:cool:

drop mic.gif

hahahahahahahahahahahahahahaha !!!
It's just for fun! Done with a smile! xD :p :D




LOL!
Well, I admit, I can't hold a candle to you. xD
I'll keep eating carrots to grow taller! :oops:
 
No, he's too good! xDxD
 

Forum statistics

Threads
111,974
Messages
590,081
Members
164,899
Latest member
mazet