我々はWebSocketをとinversify特急-utilsのに基づいて、当社のtypescriptですアプリケーションを拡張するために接続しようが、ない運これまで:ts-node server.ts
で期待通りinversify-express-utilsを使用して、WebSocketをどのように統合できますか?
import 'reflect-metadata';
import {interfaces, InversifyExpressServer, TYPE} from 'inversify-express-utils';
import { Kernel } from 'inversify';
import {UserController} from './controller/UserController';
import TYPES from './constant/types';
import * as socketIo from 'socket.io';
// set up kernel
let kernel = new Kernel();
// create server
let server = new InversifyExpressServer(kernel);
kernel.bind<interfaces.Controller>(TYPE.Controller).to(UserController).whenTargetNamed(TAGS.UserController);
server
.build()
.listen(3000, 'localhost',() => console.log('listening on http://localhost:3000'));
// try to setup a socket io based websocket
let io = socketIo(server);
io.on('connect', (socket) => console.log('"connect" executed'));
io.on('connection', (socket) => console.log('"connection" executed'));
サーバーが起動しません。 しかし、私はこのWebソケットに接続できません。たとえば、暗いウェブソケットターミナルのクロムプラグインと実行\connect localhost:3000
のようないくつかのツールでそれを試してみてください。
こんにちは、私はInversifyJSチームにこの問題を報告していると我々はhttps://github.com/inversify/InversifyJS/issues/413でそれを調査している私たちは決してありませんexpress utilsでWebソケットを使用していましたが、これは不足している機能ですが、私はあなたの更新を続けます。 –
あなたの返事をありがとう。 [InversifyJS/issues/413](http://github.com/inversify/InversifyJS/issues/413) –