diff --git a/src/kernel/net/Net.hx b/src/kernel/net/Net.hx index 5e7b710..7168689 100644 --- a/src/kernel/net/Net.hx +++ b/src/kernel/net/Net.hx @@ -1,5 +1,6 @@ package kernel.net; +import haxe.ds.ReadOnlyArray; using tink.CoreApi; import kernel.net.Package.NetworkID; @@ -37,6 +38,14 @@ class Net { for (interf in interfaces){ setupInterf(interf); } + + setupPingHandle(); + } + + private function setupPingHandle() { + this.registerProto('ping', pack -> { + this.respondTo(pack, pack.data); + }); } private function setupInterf(interf: INetworkInterface) { @@ -204,7 +213,7 @@ class Net { **/ public function ping(toID: NetworkID): Promise { return new Promise((resolve,reject)->{ - this.sendAndAwait(toID,"ping",null).map(pack -> { + this.sendAndAwait(toID,"ping",null).handle(pack -> { switch pack { case Success(_): resolve(true); @@ -215,4 +224,14 @@ class Net { return null; }); } + + public function getActiveProtocols(): ReadOnlyArray { + var arr = new Array(); + + for (proto in protoHandlers.keys()) { + arr.push(proto); + } + + return arr; + } }