Skip to content

Commit

Permalink
Remove some test code
Browse files Browse the repository at this point in the history
  • Loading branch information
C0nquistadore committed Sep 5, 2022
1 parent 879e2ee commit 61d41c1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 66 deletions.
17 changes: 0 additions & 17 deletions shared/Schemas/OpenApiSchema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,6 @@ paths:
description: Success
security:
- openIdConnect: [ ]
/TelephonyHub/SendMessage:
post:
tags:
- TelephonyHub
operationId: SendMessage
parameters:
- name: message
in: query
required: true
schema:
type: string
responses:
'204':
description: NoContent
security:
- openIdConnect: [ ]
x-websocket: true
/TelephonyHub/ReceiveCallNotification:
post:
tags:
Expand Down
7 changes: 0 additions & 7 deletions src/PhoneBox.Client/TelephonyHubListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public async Task StartAsync(CancellationToken cancellationToken)
.WithAutomaticReconnect()
.Build();
this._connection.Closed += OnHubConnectionClosed;
_ = this._connection.On<string>(this.SendMessage);
_ = this._connection.On<CallNotificationEvent>(this.ReceiveCallNotification);
_ = this._connection.On<CallStateEvent>(this.ReceiveCallState);

Expand Down Expand Up @@ -81,12 +80,6 @@ private static Task OnHubConnectionClosed(Exception? exception)
#endregion

#region ITelephonyHub Members
public Task SendMessage(string message)
{
Console.WriteLine($"Received message: {message}");
return Task.CompletedTask;
}

public Task ReceiveCallNotification(CallNotificationEvent call)
{
Console.WriteLine($"Received call notification: {call.CallerPhoneNumber} {call.CallStateKey} {call.HasCallControl} ==> {call.DebugInfo}");
Expand Down
6 changes: 0 additions & 6 deletions src/PhoneBox.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ private static async Task Main(string[] args)
services.AddSingleton<ITelephonyEventDispatcherFactory, TelephonyEventHubDispatcherFactory>();
services.AddSingleton<IUserIdProvider, SubscriberIdClaimUserIdProvider>();

if (isDevelopment)
{
// Periodically sends messages to the hub for debugging purposes
services.AddSingleton<IHostedService, TelephonyHubWorker>();
}

TelephonyConnectorRegistrar.RegisterProvider(builder);

WebApplication app = builder.Build();
Expand Down
2 changes: 1 addition & 1 deletion src/PhoneBox.Server/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "TelephonyHook/102/101",
"launchUrl": "TelephonyHook/+4917612312312/+49123456789",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
Expand Down
28 changes: 0 additions & 28 deletions src/PhoneBox.Server/SignalR/TelephonyHubWorker.cs

This file was deleted.

13 changes: 6 additions & 7 deletions src/PhoneBox.Server/WebHook/TelephonyHook.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.SignalR;
using PhoneBox.Abstractions;
using PhoneBox.Server.SignalR;

namespace PhoneBox.Server.WebHook
{
internal sealed class TelephonyHook : ITelephonyHook
{
private readonly IHubContext<TelephonyHub, ITelephonyHub> _hub;
private readonly ITelephonyEventDispatcherFactory _telephonyEventDispatcherFactory;

public TelephonyHook(IHubContext<TelephonyHub, ITelephonyHub> hub)
public TelephonyHook(ITelephonyEventDispatcherFactory telephonyEventDispatcherFactory)
{
this._hub = hub;
this._telephonyEventDispatcherFactory = telephonyEventDispatcherFactory;
}

public Task HandleGet(string fromPhoneNumber, string toPhoneNumber, HttpContext context) => this.HandleWebHookRequest(fromPhoneNumber, toPhoneNumber, context);
Expand All @@ -21,8 +19,9 @@ public TelephonyHook(IHubContext<TelephonyHub, ITelephonyHub> hub)

private async Task HandleWebHookRequest(string fromPhoneNumber, string toPhoneNumber, HttpContext context)
{
bool isAuthenticated = context.User.Identity?.IsAuthenticated == true;
await this._hub.Clients.User(toPhoneNumber).SendMessage($"Webhook called: {fromPhoneNumber} [Authenticated: {isAuthenticated}]").ConfigureAwait(false);
ITelephonyEventDispatcher telephonyEventDispatcher = this._telephonyEventDispatcherFactory.Create(new CallSubscriber(toPhoneNumber));
CallNotificationEvent notification = new CallNotificationEvent("WebHook", fromPhoneNumber, callStateKey: null, hasCallControl: false);
await telephonyEventDispatcher.OnCallNotification(notification).ConfigureAwait(false);
context.Response.StatusCode = 200;
await context.Response.WriteAsync("Thx!").ConfigureAwait(false);
}
Expand Down

0 comments on commit 61d41c1

Please sign in to comment.