added entrypoint
This commit is contained in:
parent
621dfb71ca
commit
209e40d0d5
@ -1,5 +1,5 @@
|
||||
-p src
|
||||
--main Startup
|
||||
--main kernel.Entrypoint
|
||||
|
||||
--library cctweaked:git:https://git.kapelle.org/niklas/cctweaked-haxelib.git
|
||||
--library tink_core
|
||||
|
@ -1,78 +1,12 @@
|
||||
import kernel.http.HTTPRequest.Http;
|
||||
import util.Observable;
|
||||
import lib.ui.reactive.TextElement;
|
||||
import lib.ui.reactive.ReactiveUI;
|
||||
import kernel.ui.WindowManager;
|
||||
import kernel.net.Net;
|
||||
import kernel.KernelEvents;
|
||||
import kernel.Log;
|
||||
import kernel.Init;
|
||||
import bin.Terminal;
|
||||
|
||||
using util.Extender.LambdaExtender;
|
||||
|
||||
class Startup {
|
||||
public static function main() {
|
||||
Init.initKernel();
|
||||
httpTest();
|
||||
}
|
||||
var terminal = new Terminal();
|
||||
|
||||
private static function httpTest() {
|
||||
Log.moveToOutput("main");
|
||||
// var url = "https://mock.codes/400";
|
||||
// var url = "https://jsonplaceholder.typicode.com/todos/1";
|
||||
var url = "https://domainnotexsist.net/aaaa";
|
||||
Http.request(url).handle((outcome)->{
|
||||
switch outcome{
|
||||
case Success(data):
|
||||
Log.debug(data.body);
|
||||
case Failure(failure):
|
||||
Log.error(failure.reason);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static function uiTest() {
|
||||
var context = WindowManager.instance.createNewContext();
|
||||
|
||||
var text1 = new Observable("My text");
|
||||
var text2 = new Observable("Another one");
|
||||
|
||||
var ui = new ReactiveUI(context,[
|
||||
new TextElement(text1,Orange,White,{
|
||||
onClick: (p) ->{
|
||||
text1.set("Click");
|
||||
}
|
||||
}),
|
||||
new TextElement(text2,Black,White,{
|
||||
onClick: (p)->{
|
||||
text2.set("Click");
|
||||
}
|
||||
})
|
||||
]);
|
||||
|
||||
ui.render();
|
||||
WindowManager.instance.focusContextToOutput(context,"main");
|
||||
}
|
||||
|
||||
private static function sendTest() {
|
||||
Net.instance.registerProto("ping",(pack)->{
|
||||
Log.debug("Message: " + pack.data);
|
||||
pack.respond("Hello from: "+Net.instance.networkID);
|
||||
});
|
||||
|
||||
KernelEvents.instance.onChar.handle((char)->{
|
||||
if (char == "s"){
|
||||
Log.debug("Sending to 4");
|
||||
Net.instance.sendAndAwait(4,"ping","Hello world").handle((result)->{
|
||||
switch (result){
|
||||
case Success(pack):
|
||||
Log.debug("Response: "+pack.data);
|
||||
case Failure(err):
|
||||
Log.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
terminal.execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
12
src/kernel/Entrypoint.hx
Normal file
12
src/kernel/Entrypoint.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package kernel;
|
||||
|
||||
class Entrypoint {
|
||||
public static function main() {
|
||||
Init.initKernel();
|
||||
try {
|
||||
Startup.main();
|
||||
}catch(e){
|
||||
Log.error('Error in startup: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user