Skip to content

Commit

Permalink
Calling Security.loadPolicyFile() with port 843 if Flash.loadFlashPol…
Browse files Browse the repository at this point in the history
…icyFile() has not been called.

Renaming WebSocket.loadPolicyFile() to WebSocket.loadFlashPolicyFile().
WebSocket.loadFlashPolicyFile() now expects URL including xmlsocket://.
  • Loading branch information
gimite committed Jan 11, 2011
1 parent 0d8d903 commit 6640d9d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Binary file modified WebSocketMain.swf
Binary file not shown.
Binary file modified WebSocketMainInsecure.zip
Binary file not shown.
17 changes: 14 additions & 3 deletions flash-src/WebSocketMain.as
Expand Up @@ -21,6 +21,7 @@ public class WebSocketMain extends Sprite {

private var callerUrl:String;
private var debug:Boolean = false;
private var manualPolicyFileLoaded:Boolean = false;

public function WebSocketMain() {

Expand Down Expand Up @@ -50,6 +51,9 @@ public class WebSocketMain extends Sprite {
url:String, protocol:String,
proxyHost:String = null, proxyPort:int = 0,
headers:String = null):WebSocket {
if (!manualPolicyFileLoaded) {
loadDefaultPolicyFile(url);
}
return new WebSocket(this, url, protocol, proxyHost, proxyPort, headers);
}

Expand All @@ -62,9 +66,16 @@ public class WebSocketMain extends Sprite {
return URLUtil.getServerName(this.callerUrl);
}

public function loadPolicyFile(url:String):void {
log("policy file: " + url);
Security.loadPolicyFile("xmlsocket://" + URLUtil.getServerNameWithPort(url));
private function loadDefaultPolicyFile(wsUrl:String):void {
var policyUrl:String = "xmlsocket://" + URLUtil.getServerName(wsUrl) + ":843";
log("policy file: " + policyUrl);
Security.loadPolicyFile(policyUrl);
}

public function loadManualPolicyFile(policyUrl:String):void {
log("policy file: " + policyUrl);
Security.loadPolicyFile(policyUrl);
manualPolicyFileLoaded = true;
}

public function log(message:String):void {
Expand Down
8 changes: 4 additions & 4 deletions web_socket.js
Expand Up @@ -300,10 +300,10 @@

WebSocket.__tasks = [];

WebSocket.loadPolicyFile = function(url) {
WebSocket.__addTask(function() {
WebSocket.__flash.loadPolicyFile(url);
});
WebSocket.loadFlashPolicyFile = function(url) {
WebSocket.__addTask(function() {
WebSocket.__flash.loadManualPolicyFile(url);
});
}

WebSocket.__initialize = function() {
Expand Down

0 comments on commit 6640d9d

Please sign in to comment.