start using tinker
This commit is contained in:
@@ -17,8 +17,18 @@ using util.Extender.LambdaExtender;
|
||||
Used to send and recceive packages.
|
||||
**/
|
||||
class Net{
|
||||
public static final instance:Net = new Net();
|
||||
private function new () {}
|
||||
public static var instance:Net;
|
||||
|
||||
@:allow(kernel.Init)
|
||||
private function new () {
|
||||
KernelEvents.instance.on("modem_message",(params)->{
|
||||
var pack = Package.fromEvent(params);
|
||||
handelIncomming(pack,params[1]);
|
||||
});
|
||||
allModems = Peripheral.instance.getModems();
|
||||
open();
|
||||
discoverNeighbors();
|
||||
}
|
||||
|
||||
public static inline final BRODCAST_PORT:Int = 65533;
|
||||
public static inline final MESSAGE_TIMEOUT:Int = 3;
|
||||
@@ -29,16 +39,6 @@ class Net{
|
||||
private var allModems:Array<kernel.peripherals.Modem>;
|
||||
private var routingTable: Map<Int,kernel.peripherals.Modem> = new Map();
|
||||
|
||||
public function init() {
|
||||
KernelEvents.instance.on("modem_message",(params)->{
|
||||
var pack = Package.fromEvent(params);
|
||||
handelIncomming(pack,params[1]);
|
||||
});
|
||||
allModems = Peripheral.instance.getModems();
|
||||
open();
|
||||
discoverNeighbors();
|
||||
}
|
||||
|
||||
private function handelIncomming(pack: Package, ?addr:String) {
|
||||
switch pack.type {
|
||||
case Data(_):
|
||||
|
||||
Reference in New Issue
Block a user