as3 java 交互_求大佬用 Java 实现这段 AS3 的 socket 通讯功能
最近在分析一個直播網站,初步分析后發現是在 swf 中用 socket 通訊返回的 flv 地址。
其中 Actionscript socket 通訊的關鍵代碼如下:
this._socket = new Socket();
this._socket.addEventListener(Event.CONNECT,this.onConnect);
this._socket.addEventListener(ProgressEvent.SOCKET_DATA,this.onSocketData);
this._socket.addEventListener(Event.CLOSE,this.handleClose);
this._socket.connect(this._ip,uint(this._port));
private function onConnect(param1:Event) : void
{
var _loc1_:ByteArray = new ByteArray();
_loc1_.endian = Endian.LITTLE_ENDIAN;
_loc1_.writeUnsignedInt(uint(this._sid));
_loc1_.writeUnsignedInt(uint(this._uid));
_loc1_.writeByte(this._needRotation == 0?0:1);
_loc1_.position = 0;
this._socket.writeBytes(_loc1_);
this._socket.flush();
}
private function onSocketData(param1:ProgressEvent) : void
{
if(this._socket.bytesAvailable > 0)
{
_loc5_ = new ByteArray();
this._socket.readBytes(_loc5_);
_loc5_.position = 0;
this._render.put(_loc5_);
}
}
其中幾個變量都是在 html 中由 FlashVars,向 swf 傳遞。
我嘗試用 java 寫了一下,但是始終得不到返回值。
Socket socket = new Socket("45.255.132.43", 7207);
OutputStream outputStream = socket.getOutputStream();
ByteBuffer bb = ByteBuffer.allocate(16);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putLong(2124798641L);
bb.putLong(3452777999L);
bb.put((byte)0);
bb.position(0);
outputStream.write(bb.array());
outputStream.flush();
socket.shutdownOutput();
InputStream is = socket.getInputStream();
System.out.println(is.available());
System.out.println(is.read());
特上 v2 向大佬求救。。。
總結
以上是生活随笔為你收集整理的as3 java 交互_求大佬用 Java 实现这段 AS3 的 socket 通讯功能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何做得更清晰电脑显示如何清晰
- 下一篇: 如何编写简单的bat文件