using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SocketIOComponent { /// /// The abstract base class for PrivateCallInfo and GroupCallInfo /// public abstract class CallInfo { /// /// The sender sc id /// [JsonProperty(PropertyName = "from_user_id")] public int FromUserID { get; protected set; } /// /// The sender sip id /// [JsonProperty(PropertyName = "from_sip_id")] public int FromSipID { get; protected set; } /// /// True for PTT call, false for full duplex call /// [JsonProperty(PropertyName = "is_ptt")] public bool IsPTT { get; protected set; } } /// /// Represents the private call request on Soket.IO /// public class PrivateCallInfo : CallInfo { /// /// Destination sc id /// [JsonProperty(PropertyName = "to_user_id")] public int ToUserID { get; private set; } /// /// Destination sip id /// [JsonProperty(PropertyName = "to_sip_id")] public int ToSipID { get; private set; } /// /// Constructor for the PrivateCallInfo class /// /// Source sip id /// Destination sip id /// True for ptt call, false for full duplex call public PrivateCallInfo(int fromSipID, int toSipID, bool isPTT) { FromSipID = fromSipID; ToSipID = toSipID; IsPTT = isPTT; } /// /// Returns a string that represents the current object /// /// A string that represents the current object public override string ToString() { return $"FromUserID = {FromUserID}; FromSipID = {FromSipID}; ToUserID = {ToUserID}; ToSipID = {ToSipID}; IsPTT = {IsPTT}"; } } /// /// Represents the group call request on Soket.IO /// public class GroupCallInfo : CallInfo { /// /// Destination sc id /// [JsonProperty(PropertyName = "to_group_id")] public int ToGroupID { get; private set; } /// /// Destination sip id /// [JsonProperty(PropertyName = "to_group_sip_id")] public int ToGroupSipID { get; private set; } /// /// Constructor for the PrivateCallInfo class /// /// Source sip id /// Destination sip id /// True for ptt call, false for full duplex call public GroupCallInfo(int fromSipID, int toGroupSipID, bool isPTT) { FromSipID = fromSipID; ToGroupSipID = toGroupSipID; IsPTT = isPTT; } /// /// Returns a string that represents the current object /// /// A string that represents the current object public override string ToString() { return $"FromUserID = {FromUserID}; FromSipID = {FromSipID}; ToGroupID = {ToGroupID}; ToGroupSipID = {ToGroupSipID}; IsPTT = {IsPTT}"; } } /// /// Represents the Ars message on SocketIO /// public class ArsInfo { /// /// True for on, false for off /// [JsonProperty(PropertyName = "ars")] public bool Ars { get; private set; } /// /// Sc Id of the user /// [JsonProperty(PropertyName = "user_id")] public string UserID { get; private set; } /// /// Sip Id of the user /// [JsonProperty(PropertyName = "sip_id")] public string SipID { get; private set; } /// /// Fake - always false /// [JsonProperty(PropertyName = "fake")] public bool Fake { get { return false; } } /// /// Constructor for the ArsInfo class /// /// True for on, false for off /// Subscriber id /// Sip id public ArsInfo(bool arsOn, string sc_ID, string sipID) { Ars = arsOn; UserID = sc_ID; SipID = sipID; } } /// /// Represents the Emergency message on SocketIO /// public class EmergencyInfo { /// /// Unique identifier for this emergency message /// [JsonProperty(PropertyName = "seq_id")] public String SequenceId { get; private set; } /// /// Sc Id of the user /// [JsonProperty(PropertyName = "from_user_id")] public string UserID { get; private set; } /// /// Sip Id of the user /// [JsonProperty(PropertyName = "from_sip_id")] public string SipID { get; private set; } /// /// Speed where the emergency was triggered /// [JsonProperty(PropertyName = "speed_kmh")] public double Speed { get; private set; } /// /// Latitude where the emergency was triggered /// [JsonProperty(PropertyName = "lat")] public double Latitude { get; private set; } /// /// Longitude where the emergency was triggered /// [JsonProperty(PropertyName = "lng")] public double Longitude { get; private set; } /// /// Type of emergency emergency was triggered /// [JsonProperty(PropertyName = "type")] public int EmergencyType { get; private set; } /// /// Constructor for the ArsInfo class /// public EmergencyInfo() { /* SequenceId = ""; UserID = "0"; SipID = "0"; Speed = 0; Latitude = 0; Longitude = 0; EmergencyType = 0; */ } } /// /// Represents the Emergency ACK message on SocketIO /// public class EmergencyAckInfo { /// /// Unique identifier for this emergency message /// [JsonProperty(PropertyName = "seq_id")] public String SequenceId { get; set; } /// /// Sc Id of the user /// [JsonProperty(PropertyName = "to_user_id")] public string UserID { get; set; } /// /// Sip Id of the user /// [JsonProperty(PropertyName = "to_sip_id")] public string SipID { get; set; } /// /// Speed where the emergency was triggered /// [JsonProperty(PropertyName = "who_ack_id")] public string WhoAckId { get; set; } /// /// Latitude where the emergency was triggered /// [JsonProperty(PropertyName = "who_ack_sip_id")] public string WhoAckSipId { get; set; } /// /// Constructor for the ArsInfo class /// public EmergencyAckInfo() { } } /// /// Represents the Poll Request message on SocketIO /// public class PollRequestInfo { /// /// Unique identifier for this poll request message /// [JsonProperty(PropertyName = "seq_id")] public String SequenceId { get; set; } /// /// Sc Id of the user /// [JsonProperty(PropertyName = "to_user_id")] public string UserID { get; set; } /// /// Sip Id of the user /// [JsonProperty(PropertyName = "to_sip_id")] public string SipID { get; set; } /// /// Constructor for the ArsInfo class /// public PollRequestInfo() { } } /// /// Represents the Gps message on SocketIO /// public class GpsInfo { /// /// Time of the position /// [JsonProperty(PropertyName = "unix_time")] public Int64 UnitTime { get; private set; } /// /// Sc Id of the user /// [JsonProperty(PropertyName = "from_user_id")] public string UserID { get; private set; } /// /// Sip Id of the user /// [JsonProperty(PropertyName = "from_sip_id")] public string SipID { get; private set; } /// /// Speed of the gps position /// [JsonProperty(PropertyName = "speed")] public int SpeedKmh { get; private set; } /// /// Latitude of the gps position /// [JsonProperty(PropertyName = "lat")] public double Lat { get; private set; } /// /// Longitude of the gps position /// [JsonProperty(PropertyName = "lng")] public double Lng { get; private set; } /// /// Unique identifier for the GPS of a Poll response /// [DefaultValue("0.0")] [JsonProperty(PropertyName = "seq_id", DefaultValueHandling=DefaultValueHandling.Populate)] public string SequenceId { get; private set; } /* /// /// Constructor for the GpsInfo class /// /// Time of the gps position /// Subscriber id /// Sip id /// Speed of the position /// Latitude of the position /// Longitude of the position /// public GpsInfo(Int64 unixTime, string sc_ID, string sipID, int speedKmh, double lat, double lng) : this(unixTime, sc_ID, sipID, speedKmh, lat, lng, "") { }*/ /// /// Constructor for the GpsInfo class /// /// Time of the gps position /// Subscriber id /// Sip id /// Speed of the position /// Latitude of the position /// Longitude of the position /// Mparam name="seq">Sequence id of the position in case of a poll response /// public GpsInfo(Int64 unixTime, string sc_ID, string sipID, int speedKmh, double lat, double lng, String seq) { UnitTime = unixTime; UserID = sc_ID; SipID = sipID; SpeedKmh = speedKmh; Lat = lat; Lng = lng; SequenceId = seq; } } /// /// Represents the Sms request on Socket.IO /// public class SmsInfo { /// /// Unique sequence ID /// [JsonProperty(PropertyName = "seq_id")] public string SeqID { get; private set; } /// /// The sender sc id /// [JsonProperty(PropertyName = "from_user_id")] public string FromUserID { get; private set; } /// /// The sender sip id /// [JsonProperty(PropertyName = "from_sip_id")] public string FromSipID { get; private set; } /// /// Destination sc id /// [JsonProperty(PropertyName = "to_id")] public string ToID { get; private set; } /// /// Destination sip id /// [JsonProperty(PropertyName = "to_sip_id")] public string ToSipID { get; private set; } /// /// Flag if the message is a group message /// [JsonProperty(PropertyName = "is_group")] public bool IsGroup { get; private set; } /// /// The message /// [JsonProperty(PropertyName = "message")] public string Message { get; private set; } /// /// Constructor for the SmsInfo class /// /// Unique sequence id /// Source sip ID /// SC ID of the sender /// Destination sip ID /// SC ID of the receiver /// The message /// True if is a group message, else false public SmsInfo(string seqID, string fromSipID, string fromUserID, string toSipID, string toID, string message, bool isGroup) { SeqID = seqID; FromUserID = fromUserID; FromSipID = fromSipID; ToSipID = toSipID; ToID = toID; Message = message; IsGroup = isGroup; } /// /// Returns a string that represents the current object /// /// public override string ToString() { return $"SeqID = {SeqID}; FromSipID = {FromSipID}; ToSipID = {ToSipID}; Message = {Message}; IsGroup = {IsGroup}"; } } /// /// Represents the SmsAck request on socket.IO /// public class SmsAckInfo { /// /// Sms to confirm unique sequence ID /// [JsonProperty(PropertyName = "seq_id")] public string SeqID { get; private set; } /// /// Sms to confirm destination sc id /// [JsonProperty(PropertyName = "ack_by_id")] public int AckById { get; private set; } /// /// Sms to confirm destination sip id /// [JsonProperty(PropertyName = "ack_by_sip_id")] public int AckBySipID { get; private set; } /// /// Constructor for the SmsAckInfo class /// /// Sms to confirm sequence id /// Sms to confirm sip destination public SmsAckInfo(string seqID, int ackBySipID) { SeqID = seqID; AckBySipID = ackBySipID; } public override string ToString() { return $"SeqID = {SeqID}; AckBySipID = {AckBySipID}; AckByID = {AckById}"; } } /// /// Provides data for the PrivateCallRequestReceived event /// public class PrivateCallRequestReceivedEventArgs : EventArgs { /// /// Private call request data /// public PrivateCallInfo CallInfo { get; private set; } internal PrivateCallRequestReceivedEventArgs(PrivateCallInfo privateCallInfo) { CallInfo = privateCallInfo; } } /// /// Provides data for the GroupCallRequestReceived event /// public class GroupCallRequestReceivedEventArgs : EventArgs { /// /// Group call request data /// public GroupCallInfo CallInfo { get; private set; } internal GroupCallRequestReceivedEventArgs(GroupCallInfo groupCallInfo) { CallInfo = groupCallInfo; } } /// /// Provides data for the ArsReceived event /// public class ArsReceivedEventArgs : EventArgs { /// /// Ars data /// public ArsInfo Ars { get; private set; } internal ArsReceivedEventArgs(ArsInfo ars) { Ars = ars; } } /// /// Provides data for the EmergencyReceived event /// public class EmergencyReceivedEventArgs : EventArgs { /// /// Emergency data /// public EmergencyInfo Emergency { get; private set; } internal EmergencyReceivedEventArgs(EmergencyInfo emg) { Emergency = emg; } } /// /// Provides data for the GpsReceived event /// public class GpsReceivedEventArgs : EventArgs { /// /// Ars data /// public GpsInfo Gps { get; private set; } internal GpsReceivedEventArgs(GpsInfo gps) { Gps = gps; } } /// /// Provides data for the SmsReceived event /// public class SmsReceivedEventArgs : EventArgs { /// /// Sms request data /// public SmsInfo SmsInfo { get; private set; } internal SmsReceivedEventArgs(SmsInfo smsInfo) { SmsInfo = smsInfo; } } /// /// Provides data for the SmsAckReceived event /// public class SmsAckReceivedEventArgs : EventArgs { /// /// SmsAck request data /// public SmsAckInfo SmsAckInfo { get; private set; } internal SmsAckReceivedEventArgs(SmsAckInfo smsAckInfo) { SmsAckInfo = smsAckInfo; } } }