38 lines
912 B
C#
38 lines
912 B
C#
|
using System.IO;
|
||
|
using WebSocketSharp;
|
||
|
using Newtonsoft.Json;
|
||
|
|
||
|
namespace SpookedTube;
|
||
|
|
||
|
|
||
|
public class SpookNetMessage
|
||
|
{
|
||
|
public string statusID { get; set; }
|
||
|
public string data { get; set; }
|
||
|
}
|
||
|
|
||
|
class SpookedUploader
|
||
|
{
|
||
|
public static int Upload(IPlayableVideo cameraRecording, int views, CommentUI[] comments)
|
||
|
{
|
||
|
if (cameraRecording.TryGetVideoPath(out string path))
|
||
|
{
|
||
|
if (!File.Exists(path))
|
||
|
{
|
||
|
Modal.ShowError("[SPOOKEDTUBE] File Error", $"Can't find {path}");
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
using (WebSocket ws = new(Plugin.URL.Value))
|
||
|
{
|
||
|
ws.OnMessage += (sender, evt) =>
|
||
|
{
|
||
|
SpookNetMessage message = JsonConvert.DeserializeObject<SpookNetMessage>(evt.Data);
|
||
|
};
|
||
|
|
||
|
ws.Connect();
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
}
|