Luski.Net/Luski.net/PublicServer.Incoming.cs
JacobTech 9f641e7429 Public Servers.
Added a bunch of API calls to use in public servers.
2023-08-21 10:58:17 -04:00

38 lines
1.1 KiB
C#

using System;
using System.IO;
using System.Text.Json;
using Luski.net.Enums;
using Luski.net.JsonTypes.BaseTypes;
using Luski.net.JsonTypes.WSS;
using WebSocketSharp;
using DataType = Luski.net.Enums.Public.DataType;
namespace Luski.net;
public partial class PublicServer
{
private void DataFromServer(object? sender, MessageEventArgs e)
{
if (e.IsPing) return;
try
{
BetterIncomingWSS? data = JsonSerializer.Deserialize(e.Data, BetterIncomingWSSContext.Default.BetterIncomingWSS);
switch (data?.Type)
{
case DataType.Token:
WSSLogin n = JsonSerializer.Deserialize(e.Data, WSSLoginContext.Default.WSSLogin)!;
File.WriteAllText(Storage.GetStorageDirectory(StorageDirectory.StorageInfo) + "token",
n.SessionToken);
Token = n.Token;
break;
default:
Console.WriteLine("Unknown");
break;
}
}
catch (Exception exception)
{
Exception(exception);
}
}
}