void OnMainWindow(int windowID) { GUI.DragWindow(new Rect(0, 0, 10000, 20)); connectToWall = GUI.Toggle(new Rect(GUIOffset.x + 20, GUIOffset.y + rowHeight * 0, 250, 40), connectToWall, "Connect to Server:"); string statusText = "NOT CONNECTED"; connectStatus.normal.textColor = Color.white; if (connected) { statusText = "CONNECTED"; connectStatus.normal.textColor = Color.green; } else if (connecting) { statusText = "CONNECTING"; } GUI.Label(new Rect(GUIOffset.x + 150, GUIOffset.y + rowHeight * 0 + 3, 250, 200), statusText, connectStatus); GUI.Label(new Rect(GUIOffset.x + 25, GUIOffset.y + rowHeight * 2, 120, 40), "Wall Server IP:"); wallIPAddresss = GUI.TextField(new Rect(GUIOffset.x + 150, GUIOffset.y + rowHeight * 2, 200, 40), wallIPAddresss, 25); GUI.Label(new Rect(GUIOffset.x + 25, GUIOffset.y + rowHeight * 4, 120, 40), "Wall Message Port:"); wallPort = int.Parse(GUI.TextField(new Rect(GUIOffset.x + 150, GUIOffset.y + rowHeight * 4, 200, 40), wallPort.ToString(), 25)); #if UNITY_ANDROID_PRO MobileServer mobileServer = GetComponent <MobileServer> (); mobileServer.startServer = GUI.Toggle(new Rect(GUIOffset.x + 20, GUIOffset.y + rowHeight * 6, 250, 40), mobileServer.startServer, "Mobile Server: "); string mobileServerText = "NOT RUNNING"; connectStatus.normal.textColor = Color.white; if (mobileServer.serverStarted) { mobileServerText = "RUNNING"; connectStatus.normal.textColor = Color.green; } GUI.Label(new Rect(GUIOffset.x + 150, GUIOffset.y + rowHeight * 6 + 3, 250, 200), mobileServerText, connectStatus); GUI.Label(new Rect(GUIOffset.x + 25, GUIOffset.y + rowHeight * 8, 120, 20), "Mobile Server Port:"); mobileServer.serverPort = int.Parse(GUI.TextField(new Rect(GUIOffset.x + 150, GUIOffset.y + rowHeight * 8, 200, 40), mobileServer.serverPort.ToString(), 25)); #endif }
private void demoListViewRefresh_Load(object sender, EventArgs e) { //配合LocalHtml使用,生成文件 var localHtmlPath = Path.Combine(MobileResourceManager.DefaultWebStaticPath, "demo.html"); if (File.Exists(localHtmlPath) == false) { using (FileStream stream = File.Create(localHtmlPath)) { string demoHtml = "<Html><Head></Head><Body>Hello LocalHtml</Body></Html>"; byte[] demoData = System.Text.Encoding.UTF8.GetBytes(demoHtml); stream.Write(demoData, 0, demoData.Length); stream.Close(); } } //配合Dynamic使用 if (MobileServer.IsRegisterHttpHandler("dynamic") == false) { MobileServer.RegisterHttpHandler("dynamic", new DynamicHttpContentHandler()); } }
/// <summary> /// 在服务停止时触发 /// </summary> /// <param name="server"></param> public static void OnServerStop(MobileServer server) { }
/// <summary> /// 在服务启动时触发 /// </summary> /// <param name="server"></param> public static void OnServerStart(MobileServer server) {//若是使用Smobiler Service部署,请去除下面注释 // AutomapperConfig.Init(); }
static demoCustomResource() { MobileServer.RegisterExtendHandler(Smobiler.Core.Web.ExtendHandlerType.ResourceGet, typeof(HttpCustomResourceHandler)); }
static demoCustomHttpResource() { //在此处,注册的为url地址 MobileServer.RegisterHttpHandler(resourceUrl, new HttpCustomHttpResourceHandler()); }