/// <summary> /// Sends data to specific connecting clients. /// </summary> /// <param name="connectionIds">Identifies the clients.</param> /// <param name="propertyName">Property name to send.</param> /// <param name="propertyValue">Property value to send.</param> protected void Send <T>(IList <string> connectionIds, string propertyName, T propertyValue = default(T)) { var eventArgs = new SendEventArgs { Properties = new Dictionary <string, object> { { propertyName, propertyValue } } }; foreach (string connectionId in connectionIds) { eventArgs.ConnectionIds.Add(connectionId); } Send(eventArgs); }
/// <summary> /// Sends data to the clients. /// </summary> /// <param name="args">Contains information on who to send to.</param> protected void Send(SendEventArgs args) { var delegates = RequestSend?.GetInvocationList().ToList(); if (delegates != null && delegates.Count > 0) { args.SendData = true; foreach (var d in delegates) { d.DynamicInvoke(this, args); if (!args.SendData) { break; } } } }
/// <summary> /// Handles send request from a multicast view model. /// </summary> private void VMInstance_RequestSend(object sender, SendEventArgs e) { var vmInfo = _activeVMs.FirstOrDefault(kvp => kvp.Value.Instance == sender).Value; if (vmInfo == null) { return; } var vmInstance = vmInfo.Instance; Send(vmInfo, new GroupSend { GroupName = e.GroupName, ConnectionIds = e.ConnectionIds, ExcludedConnectionIds = e.ExcludedConnectionIds, UserIds = e.UserIds, Data = vmInstance.Serialize(e.Properties) }); e.SendData = false; }