public async Task <bool> SendMessageToParticipant(string message, RemoteSystemSessionParticipant participant) { bool status = false; if (m_msgChannel == null) { m_msgChannel = new RemoteSystemSessionMessageChannel(m_currentSession, "ParticipantChannel"); } byte[] data; using (var stream = new MemoryStream()) { new DataContractJsonSerializer(message.GetType()).WriteObject(stream, message); data = stream.ToArray(); } // Send message to specific participant, in this case, the host. ValueSet sentMessage = new ValueSet { [Key] = data }; await m_msgChannel.SendValueSetAsync(sentMessage, participant); //Debug.WriteLine($"Message successfully sent to {Particpant}"); status = true; return(status); }
private async Task SendMessageToParticipantsAsync(object message, RemoteSystemSessionParticipant participant = null) { using (var stream = new MemoryStream()) { new DataContractJsonSerializer(message.GetType()).WriteObject(stream, message); byte[] data = stream.ToArray(); // Send message to all ValueSet sentMessage = new ValueSet { ["Key"] = data }; // Send specific participants if (participant == null) { await appMessageChannel.BroadcastValueSetAsync(sentMessage); } else { await appMessageChannel.SendValueSetAsync(sentMessage, participant); } } }