Esempio n. 1
0
        /// <summary>
        /// Handles incoming Response_VM message.
        /// </summary>
        private void OnResponse_VM(object payload)
        {
            if (payload is JArray == false)
            {
                return;
            }

            // SignalR .NET Core is sending an array of arguments.
            var vmId    = $"{(payload as JArray)[0]}";
            var rawData = (payload as JArray)[1].ToString();
            var data    = JsonConvert.DeserializeObject <Dictionary <string, object> >(rawData);

            var eventArgs = new ResponseVMEventArgs {
                VMId = vmId, Data = data
            };
            var args = new object[] { this, eventArgs };

            foreach (Delegate d in Response_VM?.GetInvocationList())
            {
                d.DynamicInvoke(args);
                if (eventArgs.Handled)
                {
                    break;
                }
            }

            // If we get to this point, that means the server holds a view model instance
            // whose view no longer existed.  So, tell the server to dispose the view model.
            if (!eventArgs.Handled)
            {
                var task = Dispose_VM(vmId);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Handles response received from the server.
 /// </summary>
 private void OnResponseReceived(object sender, ResponseVMEventArgs e)
 {
     if (e.VMId == _vmId)
     {
         e.Handled = true;
         _viewState.Set(Preprocess(e.Data));
     }
 }