public override async Task Register(ListenerInfo request, IServerStreamWriter <Broadcast> responseStream, ServerCallContext context) { Console.WriteLine($"Listener named \"{request.Name}\" registered."); ListenerSkeleton skeleton = new ListenerSkeleton(request, responseStream); requests.Add(skeleton); await skeleton.DoWork(); }
/// <summary> /// You can register with duplicated names, but I will only send to the first one. /// </summary> internal bool Send(string to, string msg) { ListenerSkeleton req = requests.FirstOrDefault(r => r.listener.Name == to); if (req != null) { req.Send(msg); return(true); } else { return(false); } }