小程序间通信

发布于 2024-08-28 12:23:47 字数 70 浏览 4 评论 0原文

根据我的理解,每个小程序都是独立的实体。是否可以有 小程序间通信 ? 。如果可以的话,如何实现呢?

谢谢 J

In my understanding each applets are independent entities . Is it possible to have
inter applet communication ? . If so , how it could be achieved ?

Thanks
J

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

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

发布评论

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

评论(5

养猫人 2024-09-04 12:23:47

是的。如果小程序位于同一页面并且源自同一域,则可以实现小程序间通信。您必须首先使用属性“name=value”来命名页面中的小程序,如下

<applet code="FirstApplet.class" name="firstApplet" width=nn height=nn></applet>
<applet code="SecondApplet.class" name="secondApplet" width=nn height=nn></applet>

所示: 在 FirstApplet.java 中,使用上面的内容来访问 SecondApplet:

SecondApplet secondApplet =
         (SecondApplet)getAppletContext().getApplet("secondApplet");
//invoke a method on secondApplet here

同样,您可以在 SecondApplet.java 中访问 FirstApplet

Yes. It is possible to achieve inter-applet communication if they are on the same page and originating from the same domain. You will have to name the applets in the page first using the attribute "name=value" like:

<applet code="FirstApplet.class" name="firstApplet" width=nn height=nn></applet>
<applet code="SecondApplet.class" name="secondApplet" width=nn height=nn></applet>

with above in place, in FirstApplet.java, use the following to access SecondApplet:

SecondApplet secondApplet =
         (SecondApplet)getAppletContext().getApplet("secondApplet");
//invoke a method on secondApplet here

Similarly, you can access the FirstApplet in SecondApplet.java

吻安 2024-09-04 12:23:47

是的。您可以使用 cookie,详情请参阅之前的答案< /a>.

Yes. You can use cookies, as detailed by this previous answer.

夜巴黎 2024-09-04 12:23:47

两个不受信任的小程序不应该能够进行通信。唯一的例外是它们是从同一网站启动的。这将允许他们使用 HTTP 请求对该站点进行通信,或者(如 @Matthew 所说)通过设置和读取本地 cookie 存储中的 cookie 进行通信。

Two untrusted applets should not be able to communicate. The only exception is if they were launched from the same website. This would allow them to communicate using HTTP requests to that site or (as @Matthew states) by setting and reading cookies in the local cookie store.

栀梦 2024-09-04 12:23:47

同一 Applet Context 中的两个 applet 可以很容易地进行通信。不幸的是,没有记录确定两个小程序是否处于同一上下文中。实现可能会做出令人惊讶的事情,特别是在处理错误或耗尽资源情况时。

一般来说,您应该返回到使用 LiveConnect 进行通信的浏览器,正如 Matthew Flaschen 所回答的那样。

您可以进一步与原始服务器进行通信。即使小程序是从不同的主机下载的,也可以在两个源之间建立通信路径。 HTTP,或者更好的 HTTPS,应该是与服务器通信的可靠方式。

Two applets in the same Applet Context can communicate easily enough. Unfortunately determining whether two applets are in the same context is not documented. Implementations may do surprising things, particularly when handling error or exhausted resource conditions.

Generally you should go back to the browser using LiveConnect to communicate, as Matthew Flaschen answer.

You can go further out and communicate to the originating server. Even if the applets are downloaded from different hosts, a communications path can be set up between the two origins. HTTP, or very much better HTTPS, should be a reliable way to communicate with the server.

耳根太软 2024-09-04 12:23:47

两个小程序之间进行通信的方式还有很多。我没有考虑代码。只是提到方法,
- 使用Javascript
- 静态变量
- 单例对象
- 雷米指数

There many more ways to communicate between two applet. I am not taking into the code. Just to mentions the ways,
- Using Javascript
- Static variables
- Singleton Object
- RMI

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