|
|
|
@ -18,15 +18,11 @@ namespace JXSoft {
@@ -18,15 +18,11 @@ namespace JXSoft {
|
|
|
|
|
} |
|
|
|
|
public class HttpServerView : MonoBehaviour,IController |
|
|
|
|
{ |
|
|
|
|
[Header("WebUrl")] |
|
|
|
|
public string[] prefixes; |
|
|
|
|
// Start is called before the first frame update |
|
|
|
|
void Start() |
|
|
|
|
{ |
|
|
|
|
//Debug.Log(int.Parse("AA",System.Globalization.NumberStyles.HexNumber).ToString()); |
|
|
|
|
this.RegisterMessageEvent<DYData.BluetoothGatewayData>(e => { |
|
|
|
|
Debug.Log("收到消息:"+e.ip); |
|
|
|
|
}).UnRegisterWhenGameObjectDestroyed(gameObject); |
|
|
|
|
this.GetModel<HttpServerModel>().onReceive<DYData.BluetoothGatewayData>(); |
|
|
|
|
startServer(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -35,10 +31,6 @@ namespace JXSoft {
@@ -35,10 +31,6 @@ namespace JXSoft {
|
|
|
|
|
{ |
|
|
|
|
if (this.GetUtility<HttpServerUtility>().httpServer != null && !"".Equals(this.GetUtility<HttpServerUtility>().getReceivedValue())) |
|
|
|
|
{ |
|
|
|
|
/*GameObject item = Instantiate(tcpMsgItem, tcpMsgContent); |
|
|
|
|
item.GetComponentInChildren<Text>().text = tcpUtil.receivedData; |
|
|
|
|
this.GetModel<TCPClientModel>().onDataRecived.Invoke(tcpUtil.receivedData); |
|
|
|
|
*/ |
|
|
|
|
this.GetModel<HttpServerModel>().onDataRecived.Invoke(this.GetUtility<HttpServerUtility>().receivedData); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -57,5 +49,29 @@ namespace JXSoft {
@@ -57,5 +49,29 @@ namespace JXSoft {
|
|
|
|
|
return HttpServerArchitecture.Interface; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public interface IHttpServer |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
public static class HttpServerExtention { |
|
|
|
|
public static IUnRegister RegisterMessageEvent<TResponse>(this IHttpServer self, Action<TResponse> onEvent) where TResponse : IResponse |
|
|
|
|
{ |
|
|
|
|
return HttpServerArchitecture.Interface.RegisterEvent<ResponseMsgEvent>(e => { |
|
|
|
|
if (e.res.GetType() == typeof(TResponse)) |
|
|
|
|
{ |
|
|
|
|
onEvent.Invoke((TResponse)e.res); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
public static void onReceive<TResponse>(this IHttpServer self) where TResponse : IResponse,new() |
|
|
|
|
{ |
|
|
|
|
HttpServerArchitecture.Interface.GetModel<HttpServerModel>().onReceive<TResponse>(); |
|
|
|
|
} |
|
|
|
|
public static void offReceive<TResponse>(this IHttpServer self) where TResponse : IResponse, new() |
|
|
|
|
{ |
|
|
|
|
HttpServerArchitecture.Interface.GetModel<HttpServerModel>().offReceive<TResponse>(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|