1

we are using websocket-sharp (https://github.com/sta/websocket-sharp). In our WebSocketBehavior we would like to use services that we inject with Autofac. So far we haven't found a way to do that.

How would one use DI with websocket-sharp?

larsbeck
  • 665
  • 2
  • 7
  • 11

1 Answers1

1

Ok, you have to use a Func to inject things in the constructor like so:

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

Taken from here: https://github.com/sta/websocket-sharp

larsbeck
  • 665
  • 2
  • 7
  • 11