73 lines
1.9 KiB
C#
73 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Church.Net.WebAPI.Models
|
|
{
|
|
|
|
public class SignalRMessage
|
|
{
|
|
public SignalRSession From { get; set; }
|
|
public SignalRSession Receiver { get; set; }
|
|
public string ActionType { get; set; }
|
|
public string ActionName { get; set; }
|
|
public Dictionary<string, string> Parameters { get; set; }
|
|
public string JsonValue { get; set; }
|
|
[JsonIgnore]
|
|
public object Value { get; set; }
|
|
public SignalRMessage()
|
|
{
|
|
Parameters = new Dictionary<string, string>();
|
|
|
|
}
|
|
|
|
public SignalRMessage(SignalRSession receiver, string actionType, string actionName = null, object value = null)
|
|
{
|
|
Parameters = new Dictionary<string, string>();
|
|
this.Receiver = receiver;
|
|
ActionType = actionType;
|
|
ActionName = actionName;
|
|
Value = value;
|
|
}
|
|
public SignalRMessage AddParameter(string key, string value)
|
|
{
|
|
if (!string.IsNullOrEmpty(key))
|
|
{
|
|
key = key.ToLower();
|
|
if (Parameters.ContainsKey(key))
|
|
{
|
|
Parameters[key] = value;
|
|
}
|
|
else
|
|
{
|
|
Parameters.Add(key, value);
|
|
}
|
|
}
|
|
|
|
return this;
|
|
}
|
|
public string GetParameter(string key)
|
|
{
|
|
return Parameters[key.ToLower()];
|
|
}
|
|
}
|
|
|
|
public class SignalRSession
|
|
{
|
|
public SignalRSession()
|
|
{
|
|
|
|
}
|
|
|
|
public SignalRSession(string sessionId, string name, bool isGroup = false)
|
|
{
|
|
SessionId = sessionId;
|
|
Name = name;
|
|
IsGroup = isGroup;
|
|
}
|
|
|
|
public string SessionId { get; set; }
|
|
public string Name { get; set; }
|
|
public bool IsGroup { get; set; }
|
|
}
|
|
}
|