User-1158769213 posted
Hello,
Just getting going with SignalR and trying to integrate it into a WPF app. So far I have a view model for the main window, and have code like the following to initialise the hub connection...
private void InitialiseHub() {
HubConnection connection = new HubConnection(App.FerretHubUrl);
_hubProxy = connection.CreateHubProxy("FerretHub");
_hubProxy.On("send", msg => Log += DateTime.Now.ToLongTimeString() + " - " + msg + Environment.NewLine);
_hubProxy.On("ferretDeleted", id => FerretDeleted(id));
connection.Start().Wait();
}
I'm now adding a second window, which has its own view model, and was about to copy the same code when it occurred to me that maybe I ought to create one HubConnection when the app starts, and have all view models use it.
Any comments? Do I create one shared HubConnection, or have each view model create its own?
Thanks