forked from LeenkxTeam/LNXSDK
53 lines
1.6 KiB
Haxe
53 lines
1.6 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{
|
|
var lnxConn = leenkx.network.Leenkx.connections.h["' + connection._url + '"];
|
|
if (lnxConn && lnxConn.client && lnxConn.client.torrent && lnxConn.client.torrent._peers) {
|
|
for (var p in lnxConn.client.torrent._peers) {
|
|
lnxConn.client.torrent._peers[p].conn._pc.close();
|
|
lnxConn.client.torrent._peers[p].conn.destroy();
|
|
leenkx.network.Leenkx.id.set("' + connection._url + '", p);
|
|
lnxConn.onclose();
|
|
}
|
|
}
|
|
}catch(error){
|
|
console.log("Error: " + error);
|
|
}
|
|
';
|
|
js.Syntax.code('(1, eval)({0})', script.toString());
|
|
}
|
|
runOutput(0);
|
|
}
|
|
}
|