feat: add Dial method with password support and implement ICodecCallControlsMessenger for call control messaging

This commit is contained in:
Neil Dorin 2026-06-25 20:30:48 -06:00
parent 8748157362
commit b945ecb470
7 changed files with 57 additions and 8 deletions

View file

@ -18,4 +18,11 @@ public interface ICodecCallControls : IHasDialer
/// </summary>
/// <param name="meeting">The meeting to dial</param>
void Dial(Meeting meeting);
/// <summary>
/// Dials the specified number with an optional password
/// </summary>
/// <param name="number">The number to dial</param>
/// <param name="password">The optional password for the call</param>
void Dial(string number, string password);
}

View file

@ -205,6 +205,26 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
}
public override void Dial(string number, string password)
{
Debug.LogMessage(LogEventLevel.Debug, this, "Dial: {0} with password: {1}", number, password);
var call = new CodecActiveCallItem() { Name = number, Number = number, Id = number, Status = eCodecCallStatus.Dialing, Direction = eCodecCallDirection.Outgoing, Type = eCodecCallType.Video };
ActiveCalls.Add(call);
OnCallStatusChange(call);
//ActiveCallCountFeedback.FireUpdate();
// Simulate 2-second ring, then connecting, then connected
var dialTimer = new Timer(2000) { AutoReset = false };
dialTimer.Elapsed += (s, e) =>
{
call.Type = eCodecCallType.Video;
SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connecting, call);
var connectTimer = new Timer(1000) { AutoReset = false };
connectTimer.Elapsed += (ss, ee) => SetNewCallStatusAndFireCallStatusChange(eCodecCallStatus.Connected, call);
connectTimer.Start();
};
dialTimer.Start();
}
/// <inheritdoc />
public override void EndCall(CodecActiveCallItem call)
{

View file

@ -272,6 +272,8 @@ public abstract class VideoCodecBase : ReconfigurableDevice, IRoutingSource,
/// </summary>
public abstract void Dial(string number);
public abstract void Dial(string number, string password);
/// <summary>
/// Ends the specified call
/// </summary>

View file

@ -14,12 +14,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// <summary>
/// Provides a messaging bridge for devices implementing <see cref="ICodecCallControls"/>
/// </summary>
public class ICallControlsMessenger : MessengerBase
public class ICodecCallControlsMessenger : MessengerBase
{
private readonly ICodecCallControls _callControls;
/// Initializes a new instance of the <see cref="ICallControlsMessenger"/> class.
public ICallControlsMessenger(string key, string messagePath, EssentialsDevice device)
/// Initializes a new instance of the <see cref="CodecCallControlsMessenger"/> class.
public ICodecCallControlsMessenger(string key, string messagePath, EssentialsDevice device)
: base(key, messagePath, device)
{
_callControls = device as ICodecCallControls ?? throw new ArgumentNullException(nameof(device));
@ -38,6 +38,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
AddAction("/dialMeeting", (id, content) =>
_callControls.Dial(content.ToObject<Meeting>()));
AddAction("/dialNumber", (id, content) =>
{
var message = content.ToObject<ICallControlsDialMeetingMessage>();
_callControls.Dial(message.Number, message.Password);
});
AddAction("/endCallById", (id, content) =>
{
var s = content.ToObject<MobileControlSimpleContent<string>>();
@ -113,4 +119,13 @@ namespace PepperDash.Essentials.AppServer.Messengers
public List<CodecActiveCallItem> Calls { get; set; }
}
public class ICallControlsDialMeetingMessage
{
[JsonProperty("number", Required = Required.Always)]
public string Number { get; set; }
[JsonProperty("password", NullValueHandling = NullValueHandling.Ignore)]
public string Password { get; set; }
}
}

View file

@ -143,7 +143,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
HasDirectory = true,
HasDirectorySearch = true,
DirectorySelectedFolderName = _directory.CurrentDirectoryResult?.CurrentDirectoryResults?.Count > 0 ? _directory.CurrentDirectoryResult.CurrentDirectoryResults[0].Name : null,
DirectorySelectedFolderIsNotRoot = _directory.CurrentDirectorResultIsNotDirectoryRoot?.BoolValue
DirectorySelectedFolderIsNotRoot = _directory.CurrentDirectoryResultIsNotDirectoryRoot?.BoolValue
});
}
}

View file

@ -21,7 +21,7 @@ public class IHasScheduleAwarenessMessenger : MessengerBase
protected override void RegisterActions()
{
AddAction("/schedule/fullStatus", (id, content) => SendFullScheduleObject());
AddAction("/schedule/fullStatus", (id, content) => SendFullScheduleObject(id));
}
private void CodecSchedule_MeetingEventChange(object sender, MeetingEventArgs e)
@ -45,13 +45,13 @@ public class IHasScheduleAwarenessMessenger : MessengerBase
/// <summary>
/// Helper method to send the full schedule data
/// </summary>
private void SendFullScheduleObject()
private void SendFullScheduleObject(string id = null)
{
PostStatusMessage(new FullScheduleMessage
{
Meetings = ScheduleSource.CodecSchedule.Meetings,
MeetingWarningMinutes = ScheduleSource.CodecSchedule.MeetingWarningMinutes
});
}, id);
}
}

View file

@ -172,9 +172,14 @@ namespace PepperDash.Essentials
),
new MessengerFactoryEntry(
typeof(ICodecCallControls),
(d, mp, ck) => new ICallControlsMessenger(
(d, mp, ck) => new ICodecCallControlsMessenger(
$"{d.Key}-callControls-{ck}", mp, d)
),
new MessengerFactoryEntry(
typeof(IHasScheduleAwareness),
(d, mp, ck) => new IHasScheduleAwarenessMessenger(
$"{d.Key}-schedule-{ck}", (IHasScheduleAwareness)d, mp)
),
new MessengerFactoryEntry(
typeof(IHasContentSharing),
(d, mp, ck) => new IHasContentSharingMessenger(