BililiveRecorder/BililiveRecorder.Core/Scripting/Runtime/JintFetchSync.cs

31 lines
779 B
C#
Raw Normal View History

2022-05-11 19:07:21 +08:00
using System.Net.Http;
using System.Threading.Tasks;
2022-05-11 00:20:57 +08:00
using Jint;
using Jint.Native;
using Jint.Native.Function;
namespace BililiveRecorder.Core.Scripting.Runtime
{
public class JintFetchSync : FunctionInstance
{
private static readonly JsString functionName = new JsString("fetch");
public JintFetchSync(Engine engine) : base(engine, engine.Realm, functionName)
{
}
protected override JsValue Call(JsValue thisObject, JsValue[] arguments)
{
2022-05-11 19:07:21 +08:00
var (promise, resolve, reject) = this._engine.RegisterPromise();
var task = Task.Run(() =>
{
});
var req = new HttpRequestMessage(HttpMethod.Get, "https://example.com");
return promise;
2022-05-11 00:20:57 +08:00
}
}
}