Adds SIMPLAtcJoinMap and SIMPLVtcJoinMap and implements them on respective messengers

This commit is contained in:
Neil Dorin
2019-12-19 17:11:12 -07:00
parent 08d6090bc5
commit 51ece9daff
6 changed files with 623 additions and 366 deletions

View File

@@ -16,75 +16,77 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
BasicTriList EISC;
/// <summary>
/// 221
/// </summary>
const uint BDialHangupOnHook = 221;
public SIMPLAtcJoinMap JoinMap {get; private set;}
/// <summary>
/// 251
/// </summary>
const uint BIncomingAnswer = 251;
/// <summary>
/// 252
/// </summary>
const uint BIncomingReject = 252;
/// <summary>
/// 241
/// </summary>
const uint BSpeedDial1 = 241;
/// <summary>
/// 242
/// </summary>
const uint BSpeedDial2 = 242;
/// <summary>
/// 243
/// </summary>
const uint BSpeedDial3 = 243;
/// <summary>
/// 244
/// </summary>
const uint BSpeedDial4 = 244;
///// <summary>
///// 221
///// </summary>
//const uint BDialHangupOnHook = 221;
/// <summary>
/// 201
/// </summary>
const uint SCurrentDialString = 201;
/// <summary>
/// 211
/// </summary>
const uint SCurrentCallNumber = 211;
/// <summary>
/// 212
/// </summary>
const uint SCurrentCallName = 212;
/// <summary>
/// 221
/// </summary>
const uint SHookState = 221;
/// <summary>
/// 222
/// </summary>
const uint SCallDirection = 222;
///// <summary>
///// 251
///// </summary>
//const uint BIncomingAnswer = 251;
///// <summary>
///// 252
///// </summary>
//const uint BIncomingReject = 252;
///// <summary>
///// 241
///// </summary>
//const uint BSpeedDial1 = 241;
///// <summary>
///// 242
///// </summary>
//const uint BSpeedDial2 = 242;
///// <summary>
///// 243
///// </summary>
//const uint BSpeedDial3 = 243;
///// <summary>
///// 244
///// </summary>
//const uint BSpeedDial4 = 244;
/// <summary>
/// 201-212 0-9*#
/// </summary>
Dictionary<string, uint> DTMFMap = new Dictionary<string, uint>
{
{ "1", 201 },
{ "2", 202 },
{ "3", 203 },
{ "4", 204 },
{ "5", 205 },
{ "6", 206 },
{ "7", 207 },
{ "8", 208 },
{ "9", 209 },
{ "0", 210 },
{ "*", 211 },
{ "#", 212 },
};
///// <summary>
///// 201
///// </summary>
//const uint SCurrentDialString = 201;
///// <summary>
///// 211
///// </summary>
//const uint SCurrentCallNumber = 211;
///// <summary>
///// 212
///// </summary>
//const uint SCurrentCallName = 212;
///// <summary>
///// 221
///// </summary>
//const uint SHookState = 221;
///// <summary>
///// 222
///// </summary>
//const uint SCallDirection = 222;
///// <summary>
///// 201-212 0-9*#
///// </summary>
//Dictionary<string, uint> DTMFMap = new Dictionary<string, uint>
//{
// { "1", 201 },
// { "2", 202 },
// { "3", 203 },
// { "4", 204 },
// { "5", 205 },
// { "6", 206 },
// { "7", 207 },
// { "8", 208 },
// { "9", 209 },
// { "0", 210 },
// { "*", 211 },
// { "#", 212 },
//};
/// <summary>
///
@@ -100,7 +102,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
public SIMPLAtcMessenger(string key, BasicTriList eisc, string messagePath)
: base(key, messagePath)
{
EISC = eisc;
EISC = eisc;
JoinMap = new SIMPLAtcJoinMap();
// TODO: Take in JoinStart value from config
JoinMap.OffsetJoinNumbers(201);
CurrentCallItem = new CodecActiveCallItem();
CurrentCallItem.Type = eCodecCallType.Audio;
@@ -117,9 +124,9 @@ namespace PepperDash.Essentials.AppServer.Messengers
this.PostStatusMessage(new
{
calls = GetCurrentCallList(),
currentCallString = EISC.GetString(SCurrentCallNumber),
currentDialString = EISC.GetString(SCurrentDialString),
isInCall = EISC.GetString(SHookState) == "Connected"
currentCallString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallName)),
currentDialString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentDialString)),
isInCall = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.HookState)) == "Connected"
});
}
@@ -131,26 +138,26 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
//EISC.SetStringSigAction(SCurrentDialString, s => PostStatusMessage(new { currentDialString = s }));
EISC.SetStringSigAction(SHookState, s =>
EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.HookState), s =>
{
CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
//GetCurrentCallList();
SendFullStatus();
});
EISC.SetStringSigAction(SCurrentCallNumber, s =>
EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallNumber), s =>
{
CurrentCallItem.Number = s;
SendCallsList();
});
EISC.SetStringSigAction(SCurrentCallName, s =>
EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallName), s =>
{
CurrentCallItem.Name = s;
SendCallsList();
});
EISC.SetStringSigAction(SCallDirection, s =>
EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CallDirection), s =>
{
CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true);
SendCallsList();
@@ -163,25 +170,31 @@ namespace PepperDash.Essentials.AppServer.Messengers
// Add straight pulse calls
Action<string, uint> addAction = (s, u) =>
AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
addAction("/endCallById", BDialHangupOnHook);
addAction("/endAllCalls", BDialHangupOnHook);
addAction("/acceptById", BIncomingAnswer);
addAction("/rejectById", BIncomingReject);
addAction("/speedDial1", BSpeedDial1);
addAction("/speedDial2", BSpeedDial2);
addAction("/speedDial3", BSpeedDial3);
addAction("/speedDial4", BSpeedDial4);
addAction("/endCallById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.EndCall));
addAction("/endAllCalls", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.EndCall));
addAction("/acceptById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.IncomingAnswer));
addAction("/rejectById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.IncomingReject));
var speeddialStart = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart);
var speeddialEnd = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart) + JoinMap.GetJoinSpanForKey(SIMPLAtcJoinMap.SpeedDialStart);
var speedDialIndex = 1;
for (uint i = speeddialStart; i < speeddialEnd; i++)
{
addAction(string.Format("/speedDial{0}", speedDialIndex), i);
}
// Get status
AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus));
// Dial on string
AppServerController.AddAction(MessagePath + "/dial", new Action<string>(s => EISC.SetString(SCurrentDialString, s)));
AppServerController.AddAction(MessagePath + "/dial", new Action<string>(s => EISC.SetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentDialString), s)));
// Pulse DTMF
AppServerController.AddAction(MessagePath + "/dtmf", new Action<string>(s =>
{
if (DTMFMap.ContainsKey(s))
var join = JoinMap.GetJoinForKey(s);
if (join > 0)
{
EISC.PulseBool(DTMFMap[s], 100);
EISC.PulseBool(join, 100);
}
}));
}