avm2: Implement NetConnection.close()
This commit is contained in:
parent
641a90b0d4
commit
08c707caa6
|
@ -21,8 +21,6 @@ package flash.net {
|
|||
stub_method("flash.net.NetConnection", "call");
|
||||
}
|
||||
|
||||
public function close():void {
|
||||
stub_method("flash.net.NetConnection", "close");
|
||||
}
|
||||
public native function close():void;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,3 +43,18 @@ pub fn connect<'gc>(
|
|||
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
pub fn close<'gc>(
|
||||
activation: &mut Activation<'_, 'gc>,
|
||||
this: Object<'gc>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let connection = this
|
||||
.as_net_connection()
|
||||
.expect("Must be NetConnection object");
|
||||
if let Some(previous_handle) = connection.set_handle(None) {
|
||||
NetConnections::close(&mut activation.context, previous_handle);
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package {
|
||||
|
||||
import flash.display.MovieClip;
|
||||
import flash.net.NetConnection;
|
||||
import flash.events.NetStatusEvent;
|
||||
|
||||
|
||||
public class Test extends MovieClip {
|
||||
|
||||
|
||||
public function Test() {
|
||||
var connection:NetConnection = new NetConnection();
|
||||
connection.addEventListener(NetStatusEvent.NET_STATUS, onStatusChange);
|
||||
|
||||
trace("/// connection.close()");
|
||||
connection.close();
|
||||
trace("");
|
||||
|
||||
trace("/// connection.connect(null)");
|
||||
connection.connect(null);
|
||||
trace("");
|
||||
|
||||
trace("/// connection.connect(null)");
|
||||
connection.connect(null);
|
||||
trace("");
|
||||
|
||||
trace("/// connection.close()");
|
||||
connection.close();
|
||||
trace("");
|
||||
|
||||
trace("/// connection.connect(\"http://example.org\")");
|
||||
connection.connect("http://example.org");
|
||||
trace("");
|
||||
|
||||
trace("/// connection.close()");
|
||||
connection.close();
|
||||
trace("");
|
||||
}
|
||||
|
||||
function onStatusChange(event: NetStatusEvent) {
|
||||
trace("-- NetStatusEvent.NET_STATUS event start --");
|
||||
trace("event.type = " + event.type);
|
||||
trace("event.bubbles = " + event.bubbles);
|
||||
trace("event.cancelable = " + event.cancelable);
|
||||
|
||||
var keys = [];
|
||||
for (var key in event.info) {
|
||||
keys.push(key);
|
||||
}
|
||||
keys.sort();
|
||||
for each (var key in keys) {
|
||||
trace("event.info." + key + " = " + event.info[key] + " (" + typeof(event.info[key]) + ")");
|
||||
}
|
||||
|
||||
trace("-- NetStatusEvent.NET_STATUS event end --");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/// connection.close()
|
||||
|
||||
/// connection.connect(null)
|
||||
-- NetStatusEvent.NET_STATUS event start --
|
||||
event.type = netStatus
|
||||
event.bubbles = false
|
||||
event.cancelable = false
|
||||
event.info.code = NetConnection.Connect.Success (string)
|
||||
event.info.level = status (string)
|
||||
-- NetStatusEvent.NET_STATUS event end --
|
||||
|
||||
/// connection.connect(null)
|
||||
-- NetStatusEvent.NET_STATUS event start --
|
||||
event.type = netStatus
|
||||
event.bubbles = false
|
||||
event.cancelable = false
|
||||
event.info.code = NetConnection.Connect.Closed (string)
|
||||
event.info.level = status (string)
|
||||
-- NetStatusEvent.NET_STATUS event end --
|
||||
-- NetStatusEvent.NET_STATUS event start --
|
||||
event.type = netStatus
|
||||
event.bubbles = false
|
||||
event.cancelable = false
|
||||
event.info.code = NetConnection.Connect.Success (string)
|
||||
event.info.level = status (string)
|
||||
-- NetStatusEvent.NET_STATUS event end --
|
||||
|
||||
/// connection.close()
|
||||
-- NetStatusEvent.NET_STATUS event start --
|
||||
event.type = netStatus
|
||||
event.bubbles = false
|
||||
event.cancelable = false
|
||||
event.info.code = NetConnection.Connect.Closed (string)
|
||||
event.info.level = status (string)
|
||||
-- NetStatusEvent.NET_STATUS event end --
|
||||
|
||||
/// connection.connect("http://example.org")
|
||||
|
||||
/// connection.close()
|
||||
-- NetStatusEvent.NET_STATUS event start --
|
||||
event.type = netStatus
|
||||
event.bubbles = false
|
||||
event.cancelable = false
|
||||
event.info.code = NetConnection.Connect.Closed (string)
|
||||
event.info.level = status (string)
|
||||
-- NetStatusEvent.NET_STATUS event end --
|
||||
-- NetStatusEvent.NET_STATUS event start --
|
||||
event.type = netStatus
|
||||
event.bubbles = false
|
||||
event.cancelable = false
|
||||
event.info.code = (string)
|
||||
event.info.description = (string)
|
||||
event.info.details = (string)
|
||||
event.info.level = status (string)
|
||||
-- NetStatusEvent.NET_STATUS event end --
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
num_frames = 1
|
Loading…
Reference in New Issue