mirror of
https://github.com/cadmium-im/zirconium-sharp.git
synced 2024-11-22 02:12:22 +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
|
||||
{
|
||||
[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