SafeDispatch/SocketIOComponent/CallInfo.cs

637 lines
18 KiB
C#
Raw Permalink Normal View History

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