فهرست منبع

added js connections by-name.

Nicolas Cannasse 18 سال پیش
والد
کامیت
636a2274a8
1فایلهای تغییر یافته به همراه10 افزوده شده و 2 حذف شده
  1. 10 2
      std/haxe/remoting/Connection.hx

+ 10 - 2
std/haxe/remoting/Connection.hx

@@ -141,20 +141,28 @@ class Connection implements Dynamic<Connection> {
 		#end
 		#end
 	}
 	}
 
 
-	public static function jsConnect() : Connection {
+	public static function jsConnect( ?name : String ) : Connection {
 		if( !flash.external.ExternalInterface.available )
 		if( !flash.external.ExternalInterface.available )
 			throw "External Interface not available";
 			throw "External Interface not available";
 		if( flash.external.ExternalInterface.call("haxe.remoting.Connection.jsRemoting") != "yes" )
 		if( flash.external.ExternalInterface.call("haxe.remoting.Connection.jsRemoting") != "yes" )
 			throw "haxe.remoting.Connection is not available in JavaScript";
 			throw "haxe.remoting.Connection is not available in JavaScript";
-		return new Connection(null,[]);
+		return new Connection(null,if( name == null ) [] else ["_cnx",name]);
 	}
 	}
 
 
 	#else js
 	#else js
 
 
+	static function __init__() {
+		untyped __js__("_cnx = new Object()");
+	}
+
 	static function jsRemoting() {
 	static function jsRemoting() {
 		return "yes";
 		return "yes";
 	}
 	}
 
 
+	public static function bind( name : String, obj : Dynamic ) {
+		untyped __js__("_cnx")[name] = obj;
+	}
+
 	public static function flashConnect( objId : String ) : Connection {
 	public static function flashConnect( objId : String ) : Connection {
 		var x : Dynamic = untyped window.document[objId];
 		var x : Dynamic = untyped window.document[objId];
 		if( x == null )
 		if( x == null )