forked from LeenkxTeam/LNXSDK
48 lines
1.5 KiB
Haxe
48 lines
1.5 KiB
Haxe
package leenkx.logicnode;
|
|
import leenkx.system.Event;
|
|
import leenkx.network.Connect;
|
|
import iron.object.Object;
|
|
|
|
|
|
class LeenkxCloseConnectionNode extends LogicNode {
|
|
public var property0: String;
|
|
|
|
public function new(tree:LogicTree) {
|
|
super(tree);
|
|
}
|
|
|
|
override function run(from:Int) {
|
|
var connection = inputs[1].get();
|
|
if (connection == null) return;
|
|
|
|
if(property0 == "client") {
|
|
var script = '
|
|
for (p in leenkx.network.Leenkx.connections.h["' + connection._url + '"].client.torrent._peers){
|
|
try{
|
|
leenkx.network.Leenkx.id.set("' + connection._url + '",p);
|
|
leenkx.network.Leenkx.connections.h["' + connection._url + '"].client.torrent._peers[p].conn._pc.close();
|
|
leenkx.network.Leenkx.connections.h["' + connection._url + '"].client.torrent._peers[p].conn.destroy();
|
|
leenkx.network.Leenkx.connections.h["' + connection._url + '"].onclose();
|
|
}catch(error){
|
|
console.log("Error: " + error);
|
|
}
|
|
}
|
|
';
|
|
js.Syntax.code('(1, eval)({0})', script.toString());
|
|
} else {
|
|
var script = '
|
|
try{
|
|
leenkx.network.Leenkx.connections.h["1008"].client.torrent._peers[p].conn._pc.close();
|
|
leenkx.network.Leenkx.connections.h["1008"].client.torrent._peers[p].conn.destroy();
|
|
leenkx.network.Leenkx.id.set("1008",p);
|
|
leenkx.network.Leenkx.connections.h["1008"].onclose();
|
|
}catch(error){
|
|
console.log("Error: " + error);
|
|
}
|
|
';
|
|
js.Syntax.code('(1, eval)({0})', script.toString());
|
|
}
|
|
runOutput(0);
|
|
}
|
|
}
|