58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace C4IT.API
|
|
{
|
|
/*
|
|
public delegate void ClientConnectionEventHandler(string clientId);
|
|
public delegate void ClientNameChangedEventHandler(string clientId, string newName);
|
|
public delegate void ClientGroupEventHandler(string clientId, string groupName);
|
|
|
|
public delegate void MessageReceivedEventHandler(string senderClientId, string message);
|
|
class CustomerPanelHub : Hub
|
|
{
|
|
static ConcurrentDictionary<string, string> _users = new ConcurrentDictionary<string, string>();
|
|
|
|
public static event ClientConnectionEventHandler ClientConnected;
|
|
public static event ClientConnectionEventHandler ClientDisconnected;
|
|
public static event ClientNameChangedEventHandler ClientNameChanged;
|
|
|
|
public static event ClientGroupEventHandler ClientJoinedToGroup;
|
|
public static event ClientGroupEventHandler ClientLeftGroup;
|
|
|
|
public static event MessageReceivedEventHandler MessageReceived;
|
|
|
|
public static void ClearState()
|
|
{
|
|
_users.Clear();
|
|
}
|
|
|
|
//Called when a client is connected
|
|
public override Task OnConnected()
|
|
{
|
|
_users.TryAdd(Context.ConnectionId, Context.ConnectionId);
|
|
|
|
ClientConnected?.Invoke(Context.ConnectionId);
|
|
|
|
return base.OnConnected();
|
|
}
|
|
|
|
//Called when a client is disconnected
|
|
public override Task OnDisconnected(bool stopCalled)
|
|
{
|
|
string userName;
|
|
_users.TryRemove(Context.ConnectionId, out userName);
|
|
|
|
ClientDisconnected?.Invoke(Context.ConnectionId);
|
|
|
|
return base.OnDisconnected(stopCalled);
|
|
}
|
|
}
|
|
*/
|
|
class CustomerPanelHub
|
|
{
|
|
|
|
}
|
|
}
|