Add ProtocolError mode, add JsonProperty attributes to BaseMessage

This commit is contained in:
ChronosX88 2020-06-26 22:57:13 +04:00
parent eed6727b61
commit 3a54c18af6
2 changed files with 60 additions and 7 deletions

View File

@ -1,15 +1,51 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Zirconium.Core.Models
{
public class BaseMessage
{
public string ID {get; set;}
public string MessageType {get; set;}
public string From {get; set;}
public string To {get; set;}
public bool Ok {get; set;}
public string AuthToken {get; set;}
public IDictionary<string, object> Payload {get; set;}
[JsonProperty("id")]
public string ID { get; set; }
[JsonProperty("type")]
public string MessageType { get; set; }
[JsonProperty("from")]
public string From { get; set; }
[JsonProperty("to")]
public string To { get; set; }
[JsonProperty("ok")]
public bool Ok { get; set; }
[JsonProperty("authToken")]
public string AuthToken { get; set; }
[JsonProperty("payload")]
public IDictionary<string, object> Payload { get; set; }
public BaseMessage() { }
public BaseMessage(BaseMessage message, bool reply)
{
ID = message.ID;
MessageType = message.MessageType;
if (reply)
{
From = message.To;
To = message.From;
}
else
{
From = message.From;
To = message.To;
}
Ok = message.Ok;
AuthToken = message.AuthToken;
Payload = message.Payload;
}
}
}

View File

@ -0,0 +1,17 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Zirconium.Core.Models
{
public class ProtocolError
{
[JsonProperty("errCode")]
public string ErrCode { get; set; }
[JsonProperty("errText")]
public string ErrText { get; set; }
[JsonProperty("errPayload")]
public IDictionary<string, object> ErrPayload { get; set; }
}
}