mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-30 05:15:59 +02:00
Allowing HTTP requests for source servers
This commit is contained in:
parent
cb84684517
commit
c2d086fe8e
7 changed files with 110 additions and 31 deletions
41
BeefLibs/Beefy2D/src/utils/HTTP.bf
Normal file
41
BeefLibs/Beefy2D/src/utils/HTTP.bf
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
|
||||
namespace Beefy2D.utils
|
||||
{
|
||||
class HTTPRequest
|
||||
{
|
||||
public enum HTTPResult
|
||||
{
|
||||
NotDone = -1,
|
||||
Failed = 0,
|
||||
Success = 1
|
||||
}
|
||||
|
||||
void* mNativeNetRequest;
|
||||
|
||||
[StdCall, CLink]
|
||||
static extern void* HTTP_GetFile(char8* url, char8* destPath);
|
||||
|
||||
[StdCall, CLink]
|
||||
static extern int32 HTTP_GetResult(void* netRequest, int32 waitMS);
|
||||
|
||||
[StdCall, CLink]
|
||||
static extern void HTTP_Delete(void* netRequest);
|
||||
|
||||
public ~this()
|
||||
{
|
||||
if (mNativeNetRequest != null)
|
||||
HTTP_Delete(mNativeNetRequest);
|
||||
}
|
||||
|
||||
public void GetFile(StringView url, StringView destPath)
|
||||
{
|
||||
mNativeNetRequest = HTTP_GetFile(url.ToScopeCStr!(), destPath.ToScopeCStr!());
|
||||
}
|
||||
|
||||
public HTTPResult GetResult()
|
||||
{
|
||||
return (HTTPResult)HTTP_GetResult(mNativeNetRequest, 0);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue