mirror of
https://github.com/cadmium-im/zirconium-sharp.git
synced 2024-11-08 11:41:04 +00:00
Add ProtocolError mode, add JsonProperty attributes to BaseMessage
This commit is contained in:
parent
eed6727b61
commit
3a54c18af6
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
17
src/Zirconium/Core/Models/ProtocolError.cs
Normal file
17
src/Zirconium/Core/Models/ProtocolError.cs
Normal 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; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user