Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Edge.js ( ) をつかって C# で Node.js の HTTPサーバをホストするサンプルコード。nuget で Edge.js をインストールしてください。.NET Framework 4.5 または Mono 3.4.0 が必要です。License: WTFPL 実行結果:
using EdgeJs;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace EdgeJsTest
class Program
public static async void Start()
var createWebSocketServer = Edge.Func(@"
var http = require('http');
return function (port, cb) {
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
res.end('こんにちは。Hello, world! ');
console.log(new Date());
}).listen(port, cb);
await createWebSocketServer(8080);
static void Main(string[] args)
new ManualResetEvent(false).WaitOne();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment