First implementation of sveltekit for webinterface
This commit is contained in:
@@ -1,8 +1,26 @@
|
||||
using Newtonsoft.Json;
|
||||
using ChatTwo.Code;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ChatTwo.Http.MessageProtocol;
|
||||
|
||||
#region Outgoing SSE
|
||||
/// <summary>
|
||||
/// Contains a valid tab with its assigned index
|
||||
/// </summary>
|
||||
public struct ChatTab(string name, int index)
|
||||
{
|
||||
[JsonProperty("name")] public string Name = name;
|
||||
[JsonProperty("index")] public int Index = index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains a number of tabs that are valid for the user to pick from
|
||||
/// </summary>
|
||||
public struct ChatTabList(ChatTab[] tabs)
|
||||
{
|
||||
[JsonProperty("tabs")] public ChatTab[] Tabs = tabs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains the current channel name
|
||||
/// </summary>
|
||||
@@ -13,7 +31,7 @@ public struct SwitchChannel((MessageTemplate[] ChannelName, bool Locked) channel
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains one or multiple channels that are valid for the user to pick from
|
||||
/// Contains a number of channels that are valid for the user to pick from
|
||||
/// </summary>
|
||||
public struct ChannelList(Dictionary<string, uint> channels)
|
||||
{
|
||||
@@ -50,7 +68,8 @@ public struct MessageTemplate()
|
||||
/// url = Simple url that should be clickable
|
||||
/// text = Simple text content of the message
|
||||
///
|
||||
/// empty = Ignore
|
||||
/// Note:
|
||||
/// Empty is used for invalid payloads
|
||||
/// </summary>
|
||||
[JsonProperty("payload")] public required string Payload;
|
||||
|
||||
@@ -60,14 +79,15 @@ public struct MessageTemplate()
|
||||
[JsonProperty("content")] public string Content = "";
|
||||
|
||||
/// <summary>
|
||||
/// Used for icon.
|
||||
/// Used for an icon.
|
||||
/// </summary>
|
||||
[JsonProperty("id")] public uint Id;
|
||||
|
||||
/// <summary>
|
||||
/// Used for text and url
|
||||
///
|
||||
/// Ignore if 0!
|
||||
/// Note:
|
||||
/// 0 is used for invalid colors
|
||||
/// </summary>
|
||||
[JsonProperty("color")] public uint Color;
|
||||
|
||||
@@ -99,10 +119,18 @@ public struct IncomingMessage()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Channel must be a valid uint number
|
||||
/// The channel type must be a valid <see cref="InputChannel"/>
|
||||
/// </summary>
|
||||
public struct IncomingChannel()
|
||||
{
|
||||
[JsonProperty("channel")] public uint Channel = uint.MaxValue;
|
||||
[JsonProperty("channel")] public InputChannel Channel = InputChannel.Invalid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The tabs index must be a valid int
|
||||
/// </summary>
|
||||
public struct IncomingTab()
|
||||
{
|
||||
[JsonProperty("index")] public int Index = -1;
|
||||
}
|
||||
#endregion
|
||||
@@ -3,15 +3,20 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace ChatTwo.Http.MessageProtocol;
|
||||
|
||||
// General
|
||||
public class CloseEvent() : BaseEvent("close");
|
||||
|
||||
// Tab related
|
||||
public class ChatTabListEvent(ChatTabList list) : BaseEvent("tab-list", JsonConvert.SerializeObject(list));
|
||||
public class ChatTabSwitchedEvent(ChatTab chatTab) : BaseEvent("tab-switched", JsonConvert.SerializeObject(chatTab));
|
||||
|
||||
// Input channel related
|
||||
public class ChannelListEvent(ChannelList channelList) : BaseEvent("channel-list", JsonConvert.SerializeObject(channelList));
|
||||
public class SwitchChannelEvent(SwitchChannel switchChannel) : BaseEvent("channel-switched", JsonConvert.SerializeObject(switchChannel));
|
||||
|
||||
public class SwitchChannelEvent(SwitchChannel switchChannel) : BaseEvent("switch-channel", JsonConvert.SerializeObject(switchChannel));
|
||||
|
||||
// Chat message related
|
||||
public class BulkMessagesEvent(Messages messages) : BaseEvent("bulk-messages", JsonConvert.SerializeObject(messages));
|
||||
|
||||
public class NewMessageEvent(Messages messages) : BaseEvent("new-message", JsonConvert.SerializeObject(messages));
|
||||
public class NewMessageEvent(MessageResponse message) : BaseEvent("new-message", JsonConvert.SerializeObject(message));
|
||||
|
||||
public class BaseEvent(string eventType, string? data = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user