Files
laatzen/LaaProductionWeb/LaaProductionWeb/Hubs/ExchangeHub.cs
T

74 lines
2.0 KiB
C#

namespace LaaProductionWeb.Hubs
{
using System.Threading.Tasks;
using global::ExchangeHub;
using global::ExchangeHub.Contracts;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
[HubName(ExchangeConnection.HUB_NAME)]
public class ExchangeHub : Hub, IExchangeHub
{
protected string ConnectionId
{
get => this.Context.ConnectionId;
}
protected string GroupName
{
get => this.Context
.QueryString
.Get(ExchangeConnection.GROUP_KEY);
}
public void Disposed(string groupName)
{
this.Clients
.OthersInGroup(this.GroupName)
.Disposed(this.GroupName);
this.Groups
.Remove(this.ConnectionId, this.GroupName);
}
public void StartFlow(double volumeM3H, string groupName)
{
this.Clients
.OthersInGroup(this.GroupName)
.StartFlow(volumeM3H, this.GroupName);
}
public void StartReferenceMessurement(int durationSeconds, string groupName)
{
this.Clients
.OthersInGroup(this.GroupName)
.StartReferenceMessurement(durationSeconds, groupName);
}
public void StopFlow(string groupName)
{
this.Clients
.OthersInGroup(this.GroupName)
.StopFlow(this.GroupName);
}
public void StopReferenceMessurement(double volumeM3, string groupName)
{
this.Clients
.OthersInGroup(this.GroupName)
.StopReferenceMessurement(volumeM3, this.GroupName);
}
public override async Task OnConnected()
{
await this.Groups.Add(this.ConnectionId, this.GroupName);
}
public override async Task OnDisconnected(bool stopCalled)
{
await this.Groups.Remove(this.ConnectionId, this.GroupName);
}
}
}