public Listener AddListener(Peer peer,uint id,FlowWriter writer,bool unbuffered) { if (Listeners.ContainsKey(id)) return Listeners[id]; var listener = new Listener(id, this, writer, unbuffered); string error; if (peer.OnSubscribe(listener,out error)) { Listeners[id] = listener; writer.WriteStatusResponse("Play.Reset", "Playing and resetting " + Name); writer.WriteStatusResponse("Play.Start", "Started playing " + Name); listener.Init(peer); return listener; } if (string.IsNullOrEmpty(error)) { error = "Not authorized to play " + Name; } writer.WriteStatusResponse("Play.Failed", error); throw new Exception(error); }