using System; using System.Net; using System.Net.Sockets; using SipComponent.Linx; namespace SipComponent { /// /// A implementation of the abstract SipClientClass, for Linx (as opose to Simoco) /// public class SipClientClassLinx : SipClientClass { #region Fields private LinxSipMessageGenerator _sipMessageGenerator = new LinxSipMessageGenerator(); #endregion /// /// Gets or sets a value indicating if the Asterisk server confirms sms /// Default value is false /// public bool SmsConfirmationFromServer { get { return base._smsConfirmationFromServer; } set { base._smsConfirmationFromServer = value; } } // constructor /// /// Constructor for the SipClientClassLinx /// /// domain name, name or IP address of sip server /// port number of the sip server /// port number of the local computer used for sip protocol /// user name on the sip server /// password on the sip server /// interval to send sip registration requests. Value is in seconds /// Miliseconds for the buffer that stores the received voice packets /// Number of ms to wait before the sip request times out /// Local Ip adress. If not specified, the class will search for a local ip on the same network with the sip server ip public SipClientClassLinx(string asteriskIP, int asteriskSipPort, int localSipPort, string userName, string password, int registrationInterval, int bufferMiliseconds, int requestTimeout, string localIpAddress = null) : base(asteriskIP, asteriskSipPort, localSipPort, userName, password, registrationInterval, bufferMiliseconds, requestTimeout, localIpAddress, false) { } #region Public Methods /// /// Sends a Sip Invite command to an user /// /// The sip id of the user /// Type of call: full duplex or half duplex public void SendInvite(string idToInvite, TypeOfCall typeOfCall) { base.Invite(idToInvite, typeOfCall); } /// /// Method used to send Gps Request to a Linx device /// /// The sip id to send the gps request /// The sequence id public void SendGPSRequest(string idToRequestGps, string seqID) { base.SendLinxGpsRequest(idToRequestGps, seqID); } /// /// Method used to acknowledge an emergency alarm sent by a Linx device /// /// The sip id of the Linx device public void AcknowledgeEmergencyAlarm(string linxID) { base.AcknowledgeLinxEmergencyAlarm(linxID); } /// /// Method used to start sending PTT Requests to a sip id /// /// The sip ID to send PTT Requests public new void RequestPTT(string sipID) { base.RequestPTT(sipID); } /// /// Method used to check if you received PTT Grant from the specified user /// /// The sip id of the user /// True if you received ptt Grant, else false public new bool PTTGrantReceived(string sipIDinDialogWith) { return base.PTTGrantReceived(sipIDinDialogWith); } /// /// Method used to send End PTT to a sip id /// /// The sip id to send End PTT public new void EndPTT(string sipID) { base.EndPTT(sipID); } /// /// Accepts a PTT Request from an user /// /// The sip ID of the user public new void GrantPTT(string idToGrantPTT) { base.GrantPTT(idToGrantPTT); } /// /// Method used to send Deny when you receive a PTT Request /// /// The sip ID sending PTT Request public new void DenyPTT(string idToDenyPTT) { base.DenyPTT(idToDenyPTT); } #endregion #region Abstract Implementation internal override RTPListener2 CreateRTPListener(UdpClient udpClient, bool startAliveTimer, int bufferMiliseconds, int sipIDinDialogWith, bool isGroupCall, TypeOfCall typeOfCall) { return new RTPListener2(udpClient, startAliveTimer, bufferMiliseconds, sipIDinDialogWith, isGroupCall, typeOfCall); } internal override RTPSender2 CreateRTPSender(UdpClient udpClient, int audioBitrate, IPEndPoint iPEndPoint, int v1, int v2, bool initiatedByMe, TypeOfCall typeOfCall, RtpCallType halfDuplexCallType = RtpCallType.Private) { return new RTPSender2(udpClient, audioBitrate, iPEndPoint, v1, v2, initiatedByMe, typeOfCall); } internal override SipMessageGenerator SipMessageGenerator { get { return _sipMessageGenerator; } } #endregion #region Events private object lockerGpsReportReceived = new object(); /// /// Occurs when a GPS report is received from a Linx device /// public event EventHandler GpsReportReceived { add { lock (lockerGpsReportReceived) { base.LinxGpsReportReceived += value; } } remove { lock (lockerGpsReportReceived) { base.LinxGpsReportReceived -= value; } } } private object lockerAlarmReceived = new object(); /// /// Occurs when an emergency alarm is received from a Linx device /// public event EventHandler EmergencyAlarmReceived { add { lock (lockerAlarmReceived) { base.LinxEmergencyAlarmReceived += value; } } remove { lock (lockerAlarmReceived) { base.LinxEmergencyAlarmReceived -= value; } } } private object lockerPttRequestReceived = new object(); /// /// Occurs when you receive a PTT request /// public new event EventHandler PTTrequestReceived { add { lock (lockerPttRequestReceived) { base.PTTrequestReceived += value; } } remove { lock (lockerPttRequestReceived) { base.PTTrequestReceived -= value; } } } private object lockerPTTrequestFailed = new object(); /// /// Ocurs when you send the maximum number of PTT requests and you do not receive an answer /// public new event EventHandler PTTrequestFailed { add { lock (lockerPTTrequestFailed) { base.PTTrequestFailed += value; } } remove { lock (lockerPTTrequestFailed) { base.PTTrequestFailed -= value; } } } private object lockerPTTrequestGranted = new object(); /// /// Occurs when your PTT request is accepted /// public new event EventHandler PTTrequestGranted { add { lock (lockerPTTrequestGranted) { base.PTTrequestGranted += value; } } remove { lock (lockerPTTrequestGranted) { base.PTTrequestGranted -= value; } } } private object lockerPTTrequestDenied = new object(); /// /// Ocurs when your PTT request is denied /// public new event EventHandler PTTrequestDenied { add { lock (lockerPTTrequestDenied) { base.PTTrequestDenied += value; } } remove { lock (lockerPTTrequestDenied) { base.PTTrequestDenied -= value; } } } private object lockerPTTStartReceived = new object(); /// /// Occurs when you receive a PTT Start packet /// public new event EventHandler PTTStartReceived { add { lock (lockerPTTStartReceived) { base.PTTStartReceived += value; } } remove { lock (lockerPTTStartReceived) { base.PTTStartReceived -= value; } } } private object lockerPTTEndReceived = new object(); /// /// Occurs when you receive a PTT End packet /// public new event EventHandler PTTEndReceived { add { lock (lockerPTTEndReceived) { base.PTTEndReceived += value; } } remove { lock (lockerPTTEndReceived) { base.PTTEndReceived -= value; } } } private object lockerArsReceived = new object(); /// /// Occurs when an Ars command is received from a Linx device /// public event EventHandler ArsReceived { add { lock (lockerArsReceived) { base.LinxArsReceived += value; } } remove { lock (lockerArsReceived) { base.LinxArsReceived -= value; } } } #endregion } }