63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Luski.net.Enums;
|
|
using Luski.net.Interfaces;
|
|
using Luski.net.JsonTypes;
|
|
using Luski.net.Structures.Main;
|
|
using Luski.net.Structures.Public;
|
|
using WebSocketSharp;
|
|
|
|
namespace Luski.net;
|
|
|
|
public partial class Server<TUser> where TUser : class, IAppUser, new()
|
|
{
|
|
public ServerType ServerType { get; internal set; } = ServerType.Public;
|
|
public string Domain { get; internal set; } = default!;
|
|
public IAppUser IAppUser => User;
|
|
public TUser User { get; internal set; }
|
|
public string ApiVersion { get; internal set; } = "v1";
|
|
private WebSocket? ServerOut;
|
|
internal string? Token = null, Error = null, gen = null;
|
|
internal bool CanRequest = false, login = false;
|
|
internal List<IUser> poeople = new();
|
|
internal List<MainSocketChannel> chans { get; set; } = new();
|
|
public string Cache
|
|
{
|
|
get
|
|
{
|
|
if (gen is null)
|
|
{
|
|
if (!Directory.Exists(JT)) Directory.CreateDirectory(JT);
|
|
string path = JT + "/Luski/";
|
|
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
path += "Data/";
|
|
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
path += User.Id + "/";
|
|
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
path += "Cache/";
|
|
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
path += Path.GetRandomFileName() + "/";
|
|
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
gen = path;
|
|
}
|
|
if (!Directory.Exists($"{gen}/avatars")) Directory.CreateDirectory($"{gen}/avatars");
|
|
if (!Directory.Exists($"{gen}/channels")) Directory.CreateDirectory($"{gen}/channels");
|
|
return gen;
|
|
}
|
|
}
|
|
|
|
internal static string JT
|
|
{
|
|
get
|
|
{
|
|
string tmp = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "JacobTech");
|
|
if (OperatingSystem.IsLinux())
|
|
{
|
|
tmp = Path.Combine(Environment.GetEnvironmentVariable("HOME")!, ".config/");
|
|
tmp += "JacobTech";
|
|
}
|
|
return tmp;
|
|
}
|
|
}
|
|
} |