PLayN 可以与套接字一起使用吗?

发布于 2024-12-16 00:34:53 字数 80 浏览 2 评论 0原文

我有一个java应用程序,它使用套接字连接到它的服务器。我想用 PlayN 包装它,但我找不到让套接字工作的方法(如果有的话)。 有办法,不是吗?

I have a java application that uses sockets to connect to it's server. I want to wrap it with PlayN but i can't find out the way to make sockets work if there is one at all.
There IS the way, isn't it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暗地喜欢 2024-12-23 00:34:53

PlayN 应用程序可以编译为 JavaScript 并在浏览器中运行。没有用于直接读写套接字的浏览器 API。有一个WebSockets API,目前还很原始,但至少可以通过持久连接完成客户端和服务器之间的异步消息传递。

您将无法“包装”使用普通 Java 套接字的应用程序。您可以为网络创建一个抽象层,并通过 WebSocket 路由套接字通信,但如果您希望游戏使用 HTML5 后端运行,那么这是最好的选择。

PlayN applications can be compiled to JavaScript and run in the browser. There are no browser APIs for reading and writing sockets directly. There is a WebSockets API, which is presently very primitive, but at least accomplishes asynchronous message passing between client and server over a persistent connection.

You will not be able to "wrap" an application that uses plain Java sockets. You can create an abstraction layer for your network and route the socket communications over WebSockets, but that's the best you can do if you want the game to run using the HTML5 backend.

梦巷 2024-12-23 00:34:53

如果您对 HTML 作为后端不感兴趣,而只对以某种方式支持套接字的平台感兴趣,您可以在核心项目中为网络通信创建一个抽象,并在每个特定于平台的项目中使用不同平台特定的套接字来实现它。在 HTML 中,除非你能解决网络套接字问题,否则你就不走运了。

If you are not interrested in HTML as backend but only platforms that do support sockets in one way or another you could create an abstraction for your network communication in the core project and implement it with the different platform specific sockets in each platform specific project. In HTML you are out of luck unless you can settle with web sockets.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文