/// <summary> /// Closes the connection to the muse with the given name, and removes it /// </summary> /// <param name="muse">the muse to close the connection from</param> private void CloseConnection(Muse muse) { if (!Muses.Contains(muse)) { return; } muse.Dispose(); Muses.Remove(muse); }
/// <summary> /// Connect to a muse with the given name and port /// </summary> /// <param name="port">portnumber to listen to</param> /// <param name="alias">the alias you want to give this muse</param> /// <exception cref="MuseException">When something goes whrong with connection</exception> /// <exception cref="MusePortAlreadyInUseException">When the given port is already in use</exception> /// <exception cref="MuseAliasAlreadyInUseException">When the manager is already connected with an muse with the same alias</exception> public Muse Connect(string alias, int port, SignalAddress subscriptions) { if (Muses.Any(m => m.Alias == alias)) { throw new MuseAliasAlreadyInUseException(); } if (Muses.Any(m => m.Port == port)) { throw new MusePortAlreadyInUseException(); } var muse = new Muse(alias, port); muse.Connect(subscriptions); Muses.Add(muse); muse.PacketReceived += (object sender, MusePacket e) => MusePacketReceived?.Invoke(sender, e); return(muse); }