Skip to content

Instantly share code, notes, and snippets.

@tripodsan
Last active August 29, 2015 14:17
Show Gist options
  • Save tripodsan/8ea074710e6ab40ecab1 to your computer and use it in GitHub Desktop.
Save tripodsan/8ea074710e6ab40ecab1 to your computer and use it in GitHub Desktop.
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);
});
#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