<?xml version="1.0" encoding="UTF-8" ?> | |
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one | |
or more contributor license agreements. See the NOTICE file | |
distributed with this work for additional information | |
regarding copyright ownership. The ASF licenses this file | |
to you under the Apache License, Version 2.0 (the | |
"License"); you may not use this file except in compliance | |
with the License. You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, | |
software distributed under the License is distributed on an | |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
KIND, either express or implied. See the License for the | |
specific language governing permissions and limitations | |
under the License. | |
--> | |
<library> | |
<class name="PortAvailabilityTest" extends="NetworkTest"> | |
<switch> | |
<when property="$as3"> | |
<passthrough> | |
import flash.events.*; | |
import flash.net.*; | |
import flash.system.*; | |
</passthrough> | |
</when> | |
</switch> | |
<rtmpconnection name="rtmp" autoconnect="false" debug="true" /> | |
<handler name="oninit"> | |
this.setAttribute("testName", "Port"); | |
</handler> | |
<method name="start"> | |
var hostUrl = protocol + "://" + host + ":" + port + canvas.rtmpUriPath; | |
rtmp.setAttribute("src", hostUrl); | |
this.log(": start test... " + hostUrl); | |
rtmp.connect(); | |
</method> | |
<method name="forcedStop"> | |
this.log("stopped"); | |
disconnect(); | |
</method> | |
<method name="disconnect"> | |
rtmp._nc.close(); | |
rtmp.setAttribute('status', 'disconnected'); | |
rtmp.setAttribute('stage', 0); | |
</method> | |
<handler name="onconnect" reference="rtmp"> | |
if (running) { | |
this.log("port is available\n"); | |
this.setPassed(); | |
disconnect(); | |
} | |
</handler> | |
<handler name="onerror" args="e" reference="rtmp"> | |
if (running) { | |
this.log("connection error - " + e + "\n"); | |
this.setFailed(); | |
} | |
</handler> | |
<handler name="onstatus" args="e" reference="rtmp"> | |
if (running) { | |
switch(e) { | |
case "timed out": | |
case "connection failed": | |
this.setFailed(); | |
break; | |
} | |
if($debug) Debug.write(testName + ": RTMP connect status - ", e); | |
} | |
</handler> | |
</class> | |
</library> |