avm2: Implement NetConnection.connect with a null `command`
This commit is contained in:
parent
009fab1889
commit
c295e3e481
|
@ -4,6 +4,7 @@ use crate::avm2::object::TObject;
|
||||||
use crate::avm2::{Activation, Error, Object, Value};
|
use crate::avm2::{Activation, Error, Object, Value};
|
||||||
|
|
||||||
pub mod local_connection;
|
pub mod local_connection;
|
||||||
|
pub mod net_connection;
|
||||||
pub mod net_stream;
|
pub mod net_stream;
|
||||||
pub mod object_encoding;
|
pub mod object_encoding;
|
||||||
pub mod shared_object;
|
pub mod shared_object;
|
||||||
|
|
|
@ -10,9 +10,7 @@ package flash.net {
|
||||||
public var objectEncoding:uint = NetConnection.defaultObjectEncoding;
|
public var objectEncoding:uint = NetConnection.defaultObjectEncoding;
|
||||||
|
|
||||||
|
|
||||||
public function connect(command:String, ... arguments):void {
|
public native function connect(command:String, ... arguments):void;
|
||||||
stub_method("flash.net.NetConnection", "connect");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addHeader(operation:String, mustUnderstand:Boolean = false, param:Object = null):void {
|
public function addHeader(operation:String, mustUnderstand:Boolean = false, param:Object = null):void {
|
||||||
stub_method("flash.net.NetConnection", "addHeader");
|
stub_method("flash.net.NetConnection", "addHeader");
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
use crate::{
|
||||||
|
avm2::{Activation, Avm2, Error, EventObject, Object, Value},
|
||||||
|
avm2_stub_method,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn connect<'gc>(
|
||||||
|
activation: &mut Activation<'_, 'gc>,
|
||||||
|
this: Option<Object<'gc>>,
|
||||||
|
args: &[Value<'gc>],
|
||||||
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
|
let this = this.unwrap();
|
||||||
|
if let Value::Null = args[0] {
|
||||||
|
let event = EventObject::net_status_event(
|
||||||
|
activation,
|
||||||
|
"netStatus",
|
||||||
|
&[
|
||||||
|
("code", "NetConnection.Connect.Success"),
|
||||||
|
("level", "status"),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
Avm2::dispatch_event(&mut activation.context, event, this);
|
||||||
|
return Ok(Value::Undefined);
|
||||||
|
}
|
||||||
|
avm2_stub_method!(
|
||||||
|
activation,
|
||||||
|
"flash.net.NetConnection",
|
||||||
|
"connect",
|
||||||
|
"with non-null command"
|
||||||
|
);
|
||||||
|
Ok(Value::Undefined)
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package {
|
||||||
|
import flash.net.NetConnection;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
public function Test() {
|
||||||
|
var connection = new NetConnection();
|
||||||
|
connection.addEventListener("netStatus", function(e) {
|
||||||
|
trace("Event: " + e);
|
||||||
|
trace("Code: " + e.info.code);
|
||||||
|
trace("Level: " + e.info.level);
|
||||||
|
});
|
||||||
|
trace("Calling connect");
|
||||||
|
connection.connect(null);
|
||||||
|
trace("Called connect");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
Calling connect
|
||||||
|
Event: [NetStatusEvent type="netStatus" bubbles=false cancelable=false eventPhase=2 info=[object Object]]
|
||||||
|
Code: NetConnection.Connect.Success
|
||||||
|
Level: status
|
||||||
|
Called connect
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
num_ticks = 1
|
Loading…
Reference in New Issue