简体   繁体   English

Adobe AIR应用程序作为http服务器吗?

[英]Adobe AIR application as a http server?

Is there any way to use an Adobe AIR application as a local http server? 有什么方法可以将Adobe AIR应用程序用作本地http服务器? ie Adobe AIR application listening to http://localhost:8020 and I'm able to use a browser to access the application? 即Adobe AIR应用程序正在侦听http://localhost:8020并且能够使用浏览器访问该应用程序? If I can, is it true or pseudo multithreading? 如果可以,是真的还是伪多线程?

Is there any library or code that I can look for? 我可以找到任何库或代码吗?

The ability to listen to ports is a new feature in AIR 2 , which ought to release soon but is currently in beta. 侦听端口的功能是AIR 2的一项新功能,该功能应该很快发布,但目前处于测试阶段。 If you're using version 2 though, you could certainly create an HTTP server if you want to. 如果您使用的是版本2,则可以根据需要创建HTTP服务器。 A general example of building a socket server can be found here . 此处可以找到构建套接字服务器的一般示例。

Note that AIR apps are event-driven, not threaded. 请注意,AIR应用程序是事件驱动的,而不是线程驱动的。 You can of course deal with multiple connections, so I suppose the runtime itself is driving them in different threads, but the code you write doesn't deal with threading or blocking, you just register for events on connection, data, etc. and handle them. 您当然可以处理多个连接,所以我想运行时本身会在不同的线程中驱动它们,但是您编写的代码不会处理线程或阻塞,您只需注册连接,数据等事件并进行处理他们。 (That may be what you mean by psuedo-threaded, I'm not really up on such things.) (这可能就是您所说的伪线程的意思,我并不是真的很喜欢这种事情。)

However, there is a very big caveat to this, which is that AIR is not currently recommended by Adobe for headless server-like applications. 但是,有一个很大的警告,那就是Adobe当前不建议将AIR用于无头服务器之类的应用程序。 As I understand it, there could be cases where the runtime popped up a confirmation dialog, and some things about the app might not work correctly until you remoted into the server to dismiss the dialog. 据我了解,在某些情况下,运行时会弹出一个确认对话框,有关该应用程序的某些信息可能无法正常工作,直到您远程进入服务器以关闭该对话框。

您可以为此使用HTML控件。

<mx:HTML width="100%" height="100%" id="html" x="0" y="0" location="http://localhost:80/"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM