add kcp
This commit is contained in:
17
Src/Unity/Scripts/Net/Http/BITKit.Net.Http.asmdef
Normal file
17
Src/Unity/Scripts/Net/Http/BITKit.Net.Http.asmdef
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "BITKit.Net.Http",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
Src/Unity/Scripts/Net/Http/BITKit.Net.Http.asmdef.meta
Normal file
7
Src/Unity/Scripts/Net/Http/BITKit.Net.Http.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21649feff1888e64293610f8ebbc75ee
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
55
Src/Unity/Scripts/Net/Http/UnityBasedHttpListenerService.cs
Normal file
55
Src/Unity/Scripts/Net/Http/UnityBasedHttpListenerService.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Net.Http
|
||||
{
|
||||
[CustomType(typeof(IHttpListenerService))]
|
||||
public class UnityBasedHttpListenerService : EntityComponent,IHttpListenerService
|
||||
{
|
||||
[SerializeField] private int port = 8080;
|
||||
[SerializeField] private bool autoStart = true;
|
||||
|
||||
private readonly IHttpListenerService _service = new HttpListenerService();
|
||||
public bool IsListening => _service.IsListening;
|
||||
|
||||
public int Port
|
||||
{
|
||||
get => _service.Port;
|
||||
set => _service.Port = port = value;
|
||||
}
|
||||
|
||||
public event Func<HttpListenerRequest, HttpContent> OnRequest
|
||||
{
|
||||
add => _service.OnRequest += value;
|
||||
remove => _service.OnRequest -= value;
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
if (!autoStart) return;
|
||||
_service.Port = port;
|
||||
_service.Start();
|
||||
}
|
||||
|
||||
public override void OnDestroyComponent()
|
||||
{
|
||||
_service.Stop();
|
||||
}
|
||||
|
||||
void IHttpListenerService.Start()
|
||||
{
|
||||
_service.Port = port;
|
||||
_service.Start();
|
||||
}
|
||||
void IHttpListenerService.Stop()
|
||||
{
|
||||
_service.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e491c7aaaf8f55c49b1c1b39f53ed3ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user