简体   繁体   English

通过LiveConnect将二进制数据从Javascript传递到Java Applet

[英]Passing binary data from Javascript into a Java applet via LiveConnect

I'm working on an application with a javascript front end that can receive a bunch of octets from the server (for the time being I'm using php's chr() to simulate some data). 我正在使用具有JavaScript前端的应用程序,该应用程序可以从服务器接收一堆八位位组(目前我正在使用php的chr()来模拟一些数据)。

Trying to pass the data from javascript into an applet to be manipulated is proving difficult. 事实证明,尝试将数据从javascript传递到小程序中以进行操作非常困难。 Since the data can have nulls mid-string, it looks like it gets terminated at the first null going in. It also looks like once the binary data touches a javascript variable the encoding messes with some of the bytes (or maybe that's just a problem with how I'm displaying it) 由于数据的中间字符串可以为null,因此看起来好像在第一个null输入时就终止了。看起来二进制数据一旦碰到了javascript变量,编码就混乱了一些字节(或者可能只是一个问题)以及我的显示方式)

Either way, what options do I have for taking a block of binary data, sent from a server and putting it into a Java applet to be manipulated. 无论哪种方式,对于从服务器发送来的二进制数据块并将其放入要进行操作的Java小程序中,我都有什么选择。 Is a conversion to base64 (or some other encoding) my only option if I want to maintain data integrity? 如果要保持数据完整性,是否唯一的选择是转换为base64(或其他某种编码)?

All this is new to me, so hopefully I got things across clearly. 所有这些对我来说都是新的,所以希望我能清楚地理解所有事情。

Ah the bane of liveconnect. 啊,liveconnect的祸根。
Yes, you either need or use urlencode or base64 to get your data through. 是的,您需要或使用urlencodebase64来获取数据。

Even when passing stuff from JavaScript to Flash (or back) you need to this, because the interface in between uses null terminated strings (which is just stupid, I know). 即使将内容从JavaScript传递到Flash(或传递回Flash),您也需要这样做,因为两者之间的接口使用以null终止的字符串(我知道这只是愚蠢的)。

I think that architecture when your java script gets binary data and passes it to java applet is not optimal. 我认为当您的Java脚本获取二进制数据并将其传递给Java Applet时,体系结构不是最佳的。 Did you probably think to modify applet to make it to go directly to server and get the binary data? 您是否可能考虑过修改applet,使其直接进入服务器并获取二进制数据? Without any java script? 没有任何Java脚本?

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

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