|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Net;
|
|
|
|
using System.Text;
|
|
|
|
using UnityEngine;
|
|
|
|
using QFrameworkCP;
|
|
|
|
|
|
|
|
namespace JXSoft {
|
|
|
|
public class HttpServerArchitecture : Architecture<HttpServerArchitecture>
|
|
|
|
{
|
|
|
|
protected override void Init()
|
|
|
|
{
|
|
|
|
this.RegisterUtility(new HttpServerUtility());
|
|
|
|
this.RegisterModel(new HttpServerModel());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public class HttpServerView : MonoBehaviour,IController
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void startServer() {
|
|
|
|
this.GetModel<HttpServerModel>().setPrefixes(prefixes);
|
|
|
|
bool isSuccess = this.GetModel<HttpServerModel>().Start();
|
|
|
|
Debug.Log("ServerOpen:"+isSuccess);
|
|
|
|
}
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
this.GetModel<HttpServerModel>().Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IArchitecture GetArchitecture()
|
|
|
|
{
|
|
|
|
return HttpServerArchitecture.Interface;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|