使用WebSocket-Sharp进行Autofac

时间:2017-02-08 13:32:34

标签: c# dependency-injection autofac websocket-sharp

我们正在使用websocket-sharp(https://github.com/sta/websocket-sharp)。在我们的WebSocketBehavior中,我们希望使用我们使用Autofac注入的服务。到目前为止,我们还没有办法做到这一点。

如何使用带有websocket-sharp的DI?

1 个答案:

答案 0 :(得分:0)

好的,您必须使用Func在构造函数中注入内容,如下所示:

wssv.AddWebSocketService<Chat> ("/ChatWithNyan", () => new Chat (" Nyan!"));

从这里采取:https://github.com/sta/websocket-sharp