made Net a static class
This commit is contained in:
parent
505d318ffb
commit
97c906e013
@ -26,7 +26,7 @@ import net.Net;
|
|||||||
|
|
||||||
var data = {"foo": "bar"};
|
var data = {"foo": "bar"};
|
||||||
|
|
||||||
Net.instance.sendAndAwait(netID,"protoname",data).map((response)->{
|
Net.sendAndAwait(netID,"protoname",data).map((response)->{
|
||||||
switch (response){
|
switch (response){
|
||||||
case Success(data):
|
case Success(data):
|
||||||
trace(data);
|
trace(data);
|
||||||
@ -35,7 +35,7 @@ Net.instance.sendAndAwait(netID,"protoname",data).map((response)->{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Net.instance.registerProto("res",(pack: GenericPackage)->{
|
Net.registerProto("res",(pack: GenericPackage)->{
|
||||||
var requestPack: Package<MyType> = cast pack; // Try not to use Dynamic
|
var requestPack: Package<MyType> = cast pack; // Try not to use Dynamic
|
||||||
|
|
||||||
requestPack.respond("Hello Back");
|
requestPack.respond("Hello Back");
|
||||||
|
@ -7,7 +7,7 @@ class ID implements Process {
|
|||||||
public function new() {}
|
public function new() {}
|
||||||
|
|
||||||
public function run(handle:ProcessHandle) {
|
public function run(handle:ProcessHandle) {
|
||||||
handle.writeLine("ID: " + kernel.net.Net.instance.networkID);
|
handle.writeLine("ID: " + kernel.net.Net.networkID);
|
||||||
handle.close();
|
handle.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class Net extends CLIAppBase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
registerSyncSubcommand("proto",(args)->{
|
registerSyncSubcommand("proto",(args)->{
|
||||||
var protos = kernel.net.Net.instance.getActiveProtocols();
|
var protos = kernel.net.Net.getActiveProtocols();
|
||||||
|
|
||||||
for (proto in protos) {
|
for (proto in protos) {
|
||||||
handle.writeLine(proto);
|
handle.writeLine(proto);
|
||||||
@ -50,7 +50,7 @@ class Net extends CLIAppBase {
|
|||||||
return Future.sync(false);
|
return Future.sync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return kernel.net.Net.instance.ping(toID).map(result -> {
|
return kernel.net.Net.ping(toID).map(result -> {
|
||||||
switch (result){
|
switch (result){
|
||||||
case Success(_):
|
case Success(_):
|
||||||
handle.write("Ping succeeded");
|
handle.write("Ping succeeded");
|
||||||
|
@ -21,7 +21,7 @@ class ResManager implements Process {
|
|||||||
|
|
||||||
public function run(handle:ProcessHandle) {
|
public function run(handle:ProcessHandle) {
|
||||||
this.handle = handle;
|
this.handle = handle;
|
||||||
Net.instance.registerProto("res",handlePackage);
|
Net.registerProto("res",handlePackage);
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class ResManager implements Process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function registerName(id: String){
|
private function registerName(id: String){
|
||||||
return RessourceNames.register(id, Net.instance.networkID);
|
return RessourceNames.register(id, Net.networkID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function persist(){
|
private function persist(){
|
||||||
|
@ -25,7 +25,7 @@ class SiteRessourceController implements Process {
|
|||||||
load();
|
load();
|
||||||
|
|
||||||
// Register proto
|
// Register proto
|
||||||
kernel.net.Net.instance.registerProto(SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO, this.handleMsg);
|
kernel.net.Net.registerProto(SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO, this.handleMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function handleMsg(pkg:GenericPackage) {
|
private function handleMsg(pkg:GenericPackage) {
|
||||||
|
@ -35,7 +35,7 @@ class Init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Routing.init();
|
Routing.init();
|
||||||
Net.instance = new Net();
|
Net.init();
|
||||||
|
|
||||||
GPS.instance = new GPS();
|
GPS.instance = new GPS();
|
||||||
INS.instance = new INS();
|
INS.instance = new INS();
|
||||||
|
@ -120,7 +120,7 @@ class GPS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function sendPositionRequest() {
|
private function sendPositionRequest() {
|
||||||
Net.instance.brodcastGPSRequest();
|
Net.brodcastGPSRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@:allow(kernel.net.Net)
|
@:allow(kernel.net.Net)
|
||||||
@ -131,8 +131,8 @@ class GPS {
|
|||||||
if (posAccuracy < 2) return;
|
if (posAccuracy < 2) return;
|
||||||
if (cachedPosition == null) return;
|
if (cachedPosition == null) return;
|
||||||
|
|
||||||
var response = new Package(Net.instance.networkID,pack.fromID, pack.msgID, GPSResponse(cachedPosition),null,0);
|
var response = new Package(Net.networkID,pack.fromID, pack.msgID, GPSResponse(cachedPosition),null,0);
|
||||||
iface.send(pack.fromID,Net.instance.networkID,response);
|
iface.send(pack.fromID,Net.networkID,response);
|
||||||
case GPSResponse(pos):
|
case GPSResponse(pos):
|
||||||
if (lastPositionResponse.contains({pos:pos,dist:dist})) return; // Ignore duplicate responses
|
if (lastPositionResponse.contains({pos:pos,dist:dist})) return; // Ignore duplicate responses
|
||||||
|
|
||||||
|
@ -20,20 +20,19 @@ class Net {
|
|||||||
/**
|
/**
|
||||||
Depends on: KernelEvents
|
Depends on: KernelEvents
|
||||||
**/
|
**/
|
||||||
public static var instance:Net;
|
|
||||||
public static inline final BRODCAST_PORT:Int = 65533;
|
public static inline final BRODCAST_PORT:Int = 65533;
|
||||||
public static inline final MESSAGE_TIMEOUT:Int = 3;
|
public static inline final MESSAGE_TIMEOUT:Int = 3;
|
||||||
public static inline final DEFAULT_TTL:Int = 10;
|
public static inline final DEFAULT_TTL:Int = 10;
|
||||||
|
|
||||||
public final networkID:NetworkID = OS.getComputerID();
|
public static final networkID:NetworkID = OS.getComputerID();
|
||||||
private final responseBus:Map<Int, Callback<Outcome<GenericPackage,Error>>> = new Map();
|
private static final responseBus:Map<Int, Callback<Outcome<GenericPackage,Error>>> = new Map();
|
||||||
private final protoHandlers:Map<String, Callback<GenericPackage>> = new Map();
|
private static final protoHandlers:Map<String, Callback<GenericPackage>> = new Map();
|
||||||
private var interfaces:Array<INetworkInterface>;
|
private static var interfaces:Array<INetworkInterface>;
|
||||||
|
|
||||||
@:allow(kernel.Init)
|
@:allow(kernel.Init)
|
||||||
private function new() {
|
private static function init() {
|
||||||
this.interfaces = [for (e in Peripheral.getAllModems()) e ]; // TODO: is this the way to do it?
|
interfaces = [for (e in Peripheral.getAllModems()) e ]; // TODO: is this the way to do it?
|
||||||
this.interfaces.push(Loopback.instance);
|
interfaces.push(Loopback.instance);
|
||||||
|
|
||||||
for (interf in interfaces){
|
for (interf in interfaces){
|
||||||
setupInterf(interf);
|
setupInterf(interf);
|
||||||
@ -44,11 +43,11 @@ class Net {
|
|||||||
Routing.setup();
|
Routing.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setupPingHandle() {
|
private static function setupPingHandle() {
|
||||||
this.registerProto("icmp", pack -> {
|
registerProto("icmp", pack -> {
|
||||||
switch pack.data.type {
|
switch pack.data.type {
|
||||||
case "ping":
|
case "ping":
|
||||||
this.respondTo(pack, "pong");
|
respondTo(pack, "pong");
|
||||||
case "died":
|
case "died":
|
||||||
// If we get a "died" message from a node when one of our packages ttl hits 0
|
// If we get a "died" message from a node when one of our packages ttl hits 0
|
||||||
// the `data.msgId` prop is the message id
|
// the `data.msgId` prop is the message id
|
||||||
@ -62,7 +61,7 @@ class Net {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setupInterf(interf: INetworkInterface) {
|
private static function setupInterf(interf: INetworkInterface) {
|
||||||
interf.onMessage.handle(e -> handle(e.pack,interf,e.dist));
|
interf.onMessage.handle(e -> handle(e.pack,interf,e.dist));
|
||||||
interf.listen(networkID);
|
interf.listen(networkID);
|
||||||
interf.listen(BRODCAST_PORT);
|
interf.listen(BRODCAST_PORT);
|
||||||
@ -71,8 +70,8 @@ class Net {
|
|||||||
/**
|
/**
|
||||||
Called when a new package comes in.
|
Called when a new package comes in.
|
||||||
**/
|
**/
|
||||||
private function handle(pack:GenericPackage,interf: INetworkInterface, ?dist: Float) {
|
private static function handle(pack:GenericPackage,interf: INetworkInterface, ?dist: Float) {
|
||||||
if (pack.toID == this.networkID || pack.toID == Net.BRODCAST_PORT){
|
if (pack.toID == networkID || pack.toID == Net.BRODCAST_PORT){
|
||||||
switch pack.type {
|
switch pack.type {
|
||||||
case Data(_) | DataNoResponse(_):
|
case Data(_) | DataNoResponse(_):
|
||||||
// Let a local proccess handle it
|
// Let a local proccess handle it
|
||||||
@ -99,14 +98,14 @@ class Net {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateMessageID():Int {
|
private static function generateMessageID():Int {
|
||||||
return Std.random(2147483647); // TODO: better uniqe number
|
return Std.random(2147483647); // TODO: better uniqe number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Send a message. Dont care if its reaches its destination nor it has a response.
|
Send a message. Dont care if its reaches its destination nor it has a response.
|
||||||
**/
|
**/
|
||||||
public function sendAndForget(dest:Int, proto:String, data:Dynamic) {
|
public static function sendAndForget(dest:Int, proto:String, data:Dynamic) {
|
||||||
var pack:GenericPackage = {
|
var pack:GenericPackage = {
|
||||||
toID: dest,
|
toID: dest,
|
||||||
fromID: networkID,
|
fromID: networkID,
|
||||||
@ -119,7 +118,7 @@ class Net {
|
|||||||
sendRaw(pack);
|
sendRaw(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function forwardPackage(pack: GenericPackage) {
|
private static function forwardPackage(pack: GenericPackage) {
|
||||||
if (pack.ttl == 0){
|
if (pack.ttl == 0){
|
||||||
|
|
||||||
if (pack.type.match(Data(_))) {
|
if (pack.type.match(Data(_))) {
|
||||||
@ -139,7 +138,7 @@ class Net {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function respondTo(pack:GenericPackage, data:Dynamic) {
|
public static function respondTo(pack:GenericPackage, data:Dynamic) {
|
||||||
if (pack.type.match(DataNoResponse(_))) {
|
if (pack.type.match(DataNoResponse(_))) {
|
||||||
Log.warn("Responed to a no response package. Ignoring");
|
Log.warn("Responed to a no response package. Ignoring");
|
||||||
return;
|
return;
|
||||||
@ -153,7 +152,7 @@ class Net {
|
|||||||
/**
|
/**
|
||||||
Send to package to the localy register handler based on the proto
|
Send to package to the localy register handler based on the proto
|
||||||
**/
|
**/
|
||||||
private function routeToProto(pack:GenericPackage) {
|
private static function routeToProto(pack:GenericPackage) {
|
||||||
var proto = switch pack.type {
|
var proto = switch pack.type {
|
||||||
case Data(proto):
|
case Data(proto):
|
||||||
proto;
|
proto;
|
||||||
@ -175,20 +174,20 @@ class Net {
|
|||||||
Just send the package to the right modem.
|
Just send the package to the right modem.
|
||||||
Returns true if message was send
|
Returns true if message was send
|
||||||
**/
|
**/
|
||||||
private function sendRaw(pack:GenericPackage): Bool {
|
private static function sendRaw(pack:GenericPackage): Bool {
|
||||||
var route = Routing.getRouteToID(pack.toID);
|
var route = Routing.getRouteToID(pack.toID);
|
||||||
if (route == null){
|
if (route == null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
route.interf.send(route.rep,this.networkID,pack);
|
route.interf.send(route.rep,networkID,pack);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Send a message and wait for a response.
|
Send a message and wait for a response.
|
||||||
**/
|
**/
|
||||||
public function sendAndAwait<T>(dest:NetworkID, proto:String, data:T):Promise<GenericPackage> {
|
public static function sendAndAwait<T>(dest:NetworkID, proto:String, data:T):Promise<GenericPackage> {
|
||||||
return new Promise<GenericPackage>((resolve, reject) -> {
|
return new Promise<GenericPackage>((resolve, reject) -> {
|
||||||
var pack:GenericPackage = {
|
var pack:GenericPackage = {
|
||||||
toID: dest,
|
toID: dest,
|
||||||
@ -230,7 +229,7 @@ class Net {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerProto(proto:String, callback:Callback<GenericPackage>) {
|
public static function registerProto(proto:String, callback:Callback<GenericPackage>) {
|
||||||
if (protoHandlers.exists(proto)) {
|
if (protoHandlers.exists(proto)) {
|
||||||
// Failed. Handler already exist.
|
// Failed. Handler already exist.
|
||||||
// TODO: return error
|
// TODO: return error
|
||||||
@ -240,16 +239,16 @@ class Net {
|
|||||||
protoHandlers[proto] = callback;
|
protoHandlers[proto] = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeProto(proto:String) {
|
public static function removeProto(proto:String) {
|
||||||
protoHandlers.remove(proto);
|
protoHandlers.remove(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sends a ping package to the given id. Returns true if there was a response.
|
Sends a ping package to the given id. Returns true if there was a response.
|
||||||
**/
|
**/
|
||||||
public function ping(toID: NetworkID): Promise<Noise> {
|
public static function ping(toID: NetworkID): Promise<Noise> {
|
||||||
return new Promise<Noise>((resolve,reject)->{
|
return new Promise<Noise>((resolve,reject)->{
|
||||||
this.sendAndAwait(toID,"icmp",{type:"ping"}).handle(pack -> {
|
sendAndAwait(toID,"icmp",{type:"ping"}).handle(pack -> {
|
||||||
switch pack {
|
switch pack {
|
||||||
case Success(_):
|
case Success(_):
|
||||||
resolve(Noise);
|
resolve(Noise);
|
||||||
@ -261,7 +260,7 @@ class Net {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActiveProtocols(): ReadOnlyArray<String> {
|
public static function getActiveProtocols(): ReadOnlyArray<String> {
|
||||||
var arr = new Array<String>();
|
var arr = new Array<String>();
|
||||||
|
|
||||||
for (proto in protoHandlers.keys()) {
|
for (proto in protoHandlers.keys()) {
|
||||||
@ -272,7 +271,7 @@ class Net {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@:allow(kernel.gps.GPS)
|
@:allow(kernel.gps.GPS)
|
||||||
private function brodcastGPSRequest() {
|
private static function brodcastGPSRequest() {
|
||||||
var pack: Package<Noise> = {
|
var pack: Package<Noise> = {
|
||||||
fromID: networkID,
|
fromID: networkID,
|
||||||
toID: Net.BRODCAST_PORT,
|
toID: Net.BRODCAST_PORT,
|
||||||
@ -284,7 +283,7 @@ class Net {
|
|||||||
|
|
||||||
for (modem in Peripheral.getAllModems()) {
|
for (modem in Peripheral.getAllModems()) {
|
||||||
if (!modem.isWireless()) continue;
|
if (!modem.isWireless()) continue;
|
||||||
modem.send(Net.BRODCAST_PORT, Net.instance.networkID, pack);
|
modem.send(Net.BRODCAST_PORT, networkID, pack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,9 @@ enum PackageTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Wrapper for `Net.instance.respondTo`.
|
Wrapper for `Net.respondTo`.
|
||||||
**/
|
**/
|
||||||
public function respond(data:Dynamic) {
|
public function respond(data:Dynamic) {
|
||||||
Net.instance.respondTo(this, data);
|
Net.respondTo(this, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class Routing {
|
|||||||
|
|
||||||
@:allow(kernel.net.Net)
|
@:allow(kernel.net.Net)
|
||||||
private static function setup() {
|
private static function setup() {
|
||||||
routingTable.set(Net.instance.networkID, {interf: Loopback.instance, cost: 0, rep: Net.instance.networkID});
|
routingTable.set(Net.networkID, {interf: Loopback.instance, cost: 0, rep: Net.networkID});
|
||||||
brodcastRoutingTable();
|
brodcastRoutingTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class Routing {
|
|||||||
var pack = newRoutDiscoverPackage();
|
var pack = newRoutDiscoverPackage();
|
||||||
|
|
||||||
for (modem in Peripheral.getAllModems()) {
|
for (modem in Peripheral.getAllModems()) {
|
||||||
modem.send(Net.BRODCAST_PORT, Net.instance.networkID, pack);
|
modem.send(Net.BRODCAST_PORT, Net.networkID, pack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,14 +103,14 @@ class Routing {
|
|||||||
// Respond to peer
|
// Respond to peer
|
||||||
var response:Package<Noise> = {
|
var response:Package<Noise> = {
|
||||||
toID: pack.fromID,
|
toID: pack.fromID,
|
||||||
fromID: Net.instance.networkID,
|
fromID: Net.networkID,
|
||||||
msgID: null,
|
msgID: null,
|
||||||
type: RouteDiscoverResponse(genRouteList()),
|
type: RouteDiscoverResponse(genRouteList()),
|
||||||
data: null,
|
data: null,
|
||||||
ttl: 0, // Prevent forwarding
|
ttl: 0, // Prevent forwarding
|
||||||
}
|
}
|
||||||
|
|
||||||
interf.send(response.toID, Net.instance.networkID, response);
|
interf.send(response.toID, Net.networkID, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,7 +132,7 @@ class Routing {
|
|||||||
type: RouteDiscover(genRouteList()),
|
type: RouteDiscover(genRouteList()),
|
||||||
toID: Net.BRODCAST_PORT,
|
toID: Net.BRODCAST_PORT,
|
||||||
msgID: null,
|
msgID: null,
|
||||||
fromID: Net.instance.networkID,
|
fromID: Net.networkID,
|
||||||
data: null,
|
data: null,
|
||||||
ttl: 0, // Prevent forwarding
|
ttl: 0, // Prevent forwarding
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ class Routing {
|
|||||||
Its possible to be called multiple times with the same id but different addr.
|
Its possible to be called multiple times with the same id but different addr.
|
||||||
**/
|
**/
|
||||||
private static function addPossibleRoute(toID:Int, interf:INetworkInterface, cost:Int, rep:NetworkID) {
|
private static function addPossibleRoute(toID:Int, interf:INetworkInterface, cost:Int, rep:NetworkID) {
|
||||||
if (toID == Net.instance.networkID) {
|
if (toID == Net.networkID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,8 +164,8 @@ class Routing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getRouteToID(networkID:NetworkID):{interf:INetworkInterface, rep:NetworkID} {
|
public static function getRouteToID(networkID:NetworkID):{interf:INetworkInterface, rep:NetworkID} {
|
||||||
if (networkID == Net.instance.networkID) {
|
if (networkID == Net.networkID) {
|
||||||
return {interf: Loopback.instance, rep: Net.instance.networkID};
|
return {interf: Loopback.instance, rep: Net.networkID};
|
||||||
}
|
}
|
||||||
|
|
||||||
var route:Null<Route> = routingTable[networkID];
|
var route:Null<Route> = routingTable[networkID];
|
||||||
|
@ -45,7 +45,7 @@ class Debug {
|
|||||||
|
|
||||||
#if webconsole
|
#if webconsole
|
||||||
public static function printWeb(msg:String) {
|
public static function printWeb(msg:String) {
|
||||||
HTTP.request("http://127.0.0.1:8080/"+Net.instance.networkID,msg);
|
HTTP.request("http://127.0.0.1:8080/"+Net.networkID,msg);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ class RessourceNames {
|
|||||||
|
|
||||||
var payload: GetRequest = {name: name, type: "get"};
|
var payload: GetRequest = {name: name, type: "get"};
|
||||||
|
|
||||||
return Net.instance.sendAndAwait(
|
return Net.sendAndAwait(
|
||||||
controllerID,
|
controllerID,
|
||||||
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
|
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
|
||||||
payload
|
payload
|
||||||
@ -36,7 +36,7 @@ class RessourceNames {
|
|||||||
|
|
||||||
var payload: RegisterRequest = {name: name, netID: netID, type: "register"};
|
var payload: RegisterRequest = {name: name, netID: netID, type: "register"};
|
||||||
|
|
||||||
return Net.instance.sendAndAwait(
|
return Net.sendAndAwait(
|
||||||
controllerID,
|
controllerID,
|
||||||
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
|
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
|
||||||
payload
|
payload
|
||||||
@ -56,7 +56,7 @@ class RessourceNames {
|
|||||||
|
|
||||||
var payload: UnregisterRequest = {name: name, type: "unregister"};
|
var payload: UnregisterRequest = {name: name, type: "unregister"};
|
||||||
|
|
||||||
return Net.instance.sendAndAwait(
|
return Net.sendAndAwait(
|
||||||
controllerID,
|
controllerID,
|
||||||
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
|
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
|
||||||
payload
|
payload
|
||||||
@ -68,7 +68,7 @@ class RessourceNames {
|
|||||||
|
|
||||||
var payload: ListRequest = {type: "list"};
|
var payload: ListRequest = {type: "list"};
|
||||||
|
|
||||||
return Net.instance.sendAndAwait(
|
return Net.sendAndAwait(
|
||||||
controllerID,
|
controllerID,
|
||||||
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
|
SiteRessourceController.SITE_CONTROLLER_RESSOURCE_MANAGER_PROTO,
|
||||||
payload
|
payload
|
||||||
|
@ -15,7 +15,7 @@ class Import {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static function performRequest(netID: NetworkID, request: Request): Promise<Response> {
|
private static function performRequest(netID: NetworkID, request: Request): Promise<Response> {
|
||||||
return Net.instance.sendAndAwait(netID,"res",request).map((response)->{
|
return Net.sendAndAwait(netID,"res",request).map((response)->{
|
||||||
switch (response){
|
switch (response){
|
||||||
case Success(data):
|
case Success(data):
|
||||||
return Success(cast (data.data, Response));
|
return Success(cast (data.data, Response));
|
||||||
|
@ -71,7 +71,7 @@ class RPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return macro {
|
return macro {
|
||||||
kernel.net.Net.instance.registerProto($v{proto},(pack)->{
|
kernel.net.Net.registerProto($v{proto},(pack)->{
|
||||||
$a{exprs}
|
$a{exprs}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@ abstract class RPCBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function _performRequest(func: String, args: Array<Dynamic>):Promise<Dynamic> {
|
private function _performRequest(func: String, args: Array<Dynamic>):Promise<Dynamic> {
|
||||||
return Net.instance.sendAndAwait(id, this._proto, {
|
return Net.sendAndAwait(id, this._proto, {
|
||||||
func: func,
|
func: func,
|
||||||
// args: args
|
// args: args
|
||||||
}).map((res) -> {
|
}).map((res) -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user