I am working on this project where there is a website that downloads real-time data through the wcf duplex service on the remote server. Updates have a frequency of about a second, and I use the SignalR client side to update the view. (Each time I get an incoming “package”, I notify my clients).
I am currently having some problems with this solution due to how the duplex service works. Whenever there is no “real time” connection with the server server serving it with data, the service should simply click on the last database record on my client. This works, but browsing my clients does not seem to fit correctly. If I try to update the view, it will actually be random, which values are updated from time to time. (When debugging, all values are contained in notification methods)
I tried using jquery / ajax to invoke a method in my controller that establishes such connections as follows:
setTimeout(function() { $.ajax({ type: 'GET', url: '@Url.Action("ConnectToDataSources", "Fleet")', cache: false, success: function (result) { } }); }, 1000)
And in my controller:
public void ConnectToDataSources() { UnitContract[] listOfUnitsFromService = UnitClient.GetUnits(false, "", false); Model = new FleetModel { UnitDetails = GenerateUnitDetails(listOfUnitsFromService.ToList()), }; foreach (UnitDetailsModel unit in Model.UnitDetails) { var ods = new OperationDataSource(); var ads = new ActivityStatusDataSource(); ads.Start(unit.UnitId, ActivityReceived, AliveReceived); ods.Start(DataReceived, unit.UnitId); _dataSources.Add(ods); _activityStatusDataSources.Add(ads); } }
After a lot of trial and error, I considered changing the backend service to use SignalR. Did I understand correctly that SignalR can actually replace the functionality described above on the server and on the client?
Also, if someone has the same setup, I’m very interested to know how you solved this problem :)
Nicklas pouey-winger
source share