Last active
August 29, 2015 14:17
-
-
Save tripodsan/8ea074710e6ab40ecab1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('init.js started'); | |
var http = require('http'); | |
http.get("http://127.0.0.1:8080/index.html", function(res) { | |
console.log("Got response: " + res.statusCode); | |
}).on('error', function(e) { | |
console.log("Got error: " + e.message); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Nodelike/Nodelike.h> | |
#import "Webkit/Webkit.h" | |
#import "AppDelegate.h" | |
@interface AppDelegate () | |
@property (weak) IBOutlet NSWindow *window; | |
@property (retain) NLContext *context; | |
@end | |
@implementation AppDelegate | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | |
NSLog(@"Starting javascriptcore native engine"); | |
JSVirtualMachine* vm = [[JSVirtualMachine alloc]init]; | |
_context = [[NLContext alloc] initWithVirtualMachine:vm]; | |
NSString *initjs = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"init" ofType:@"js"] encoding:(NSUTF8StringEncoding) error:NULL]; | |
[_context evaluateScript:initjs]; | |
[NLContext runEventLoopAsyncInContext:_context]; | |
} | |
- (void)applicationWillTerminate:(NSNotification *)aNotification { | |
[NLContext emitExit:_context]; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment