SafeDispatch/MotoTrbo_GW/LINX/ClassDefinitions.cs

127 lines
3.3 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MotoTrbo_GW.LINX
{
public class RadioSipInfo
{
public SipComponent.SipClientClass2 SipClass { get; private set; }
public SafeMobileLib.ContactLinx ContactInfo { get; private set; }
public RadioSipInfo(SipComponent.SipClientClass2 sipClass, SafeMobileLib.ContactLinx contactInfo)
{
this.SipClass = sipClass;
this.ContactInfo = contactInfo;
}
}
public struct LinxCall
{
private readonly string _linxSipID;
public string LinxSipID { get { return _linxSipID; } }
private readonly int _radioSipID;
public int RadioSipID { get { return _radioSipID; } }
public LinxCall(string linxSipID, int radioSipID)
{
this._linxSipID = linxSipID;
this._radioSipID = radioSipID;
}
public static LinxCall DefaultValue
{
get { return new LinxCall(); }
}
public override bool Equals(object obj)
{
if (obj == null) return false;
if (obj is LinxCall)
{
LinxCall objLinxCall = (LinxCall)obj;
return objLinxCall.LinxSipID == this.LinxSipID && objLinxCall.RadioSipID == this.RadioSipID;
}
else return false;
}
public static bool operator ==(LinxCall s1, LinxCall s2)
{
return s1.Equals(s2);
}
public static bool operator !=(LinxCall s1, LinxCall s2)
{
return !s1.Equals(s2);
}
}
public class RadioIdKey
{
private string _groupInfo;
public int RadioID { get; private set; }
public bool IsGroup { get; private set; }
public RadioIdKey(int radioID, bool isGroup)
{
RadioID = radioID;
IsGroup = isGroup;
_groupInfo = IsGroup ? "1" : "0";
}
public override int GetHashCode()
{
return (RadioID.ToString() + _groupInfo).GetHashCode();
}
public override bool Equals(object obj)
{
RadioIdKey other = (RadioIdKey)obj;
if (other.RadioID == this.RadioID)
{
if (other.IsGroup == this.IsGroup)
{
return true;
}
else
return false;
}
else return false;
}
}
public class RadioVoiceToLinxEventArgs : EventArgs
{
public byte[] VoiceBuffer { get; private set; }
public int BufferLength { get; private set; }
public RadioVoiceToLinxEventArgs(byte[] buffer, int bufferLength)
{
this.VoiceBuffer = buffer;
this.BufferLength = bufferLength;
}
}
public class CallLinxEventArgs : EventArgs
{
public int RadioID { get; private set; }
public int GroupID { get; private set; } = -1;
public bool IsGroup { get; private set; }
public CallLinxEventArgs(int radioID, bool isGroup, int groupID)
{
this.RadioID = radioID;
this.IsGroup = isGroup;
if (isGroup)
this.GroupID = groupID;
}
}
}