You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
53 lines
1.1 KiB
using Connected.Interop.Reflection;
|
|
|
|
namespace Connected.Net.Hubs;
|
|
|
|
public enum MessageClientBehavior
|
|
{
|
|
Reliable = 1,
|
|
FireForget = 2
|
|
}
|
|
|
|
public sealed class Client<TArgs> : IComparable<Client<TArgs>>
|
|
{
|
|
public Client(string connection)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(connection))
|
|
throw new ArgumentException(null, nameof(connection));
|
|
|
|
Connection = connection;
|
|
}
|
|
|
|
public string Connection { get; set; }
|
|
public int User { get; set; }
|
|
public TArgs? Arguments { get; set; }
|
|
public DateTime RetentionDeadline { get; set; }
|
|
public MessageClientBehavior Behavior { get; set; } = MessageClientBehavior.Reliable;
|
|
|
|
public int CompareTo(Client<TArgs>? other)
|
|
{
|
|
if (other is null)
|
|
return 1;
|
|
|
|
if (User != other.User)
|
|
return 1;
|
|
|
|
if (Behavior != other.Behavior)
|
|
return 1;
|
|
|
|
if (Arguments is null && other.Arguments is null)
|
|
return 0;
|
|
|
|
if (Arguments is null && other.Arguments is not null)
|
|
return -1;
|
|
|
|
if (Arguments is not null && other.Arguments is null)
|
|
return 1;
|
|
|
|
if (ObjectComparer.Compare(Arguments, other.Arguments))
|
|
return 0;
|
|
|
|
return -1;
|
|
}
|
|
}
|