Пример #1
0
        private Socket GetServerSocket(Socket client)
        {
            TrackInfo track = Banshee.ServiceStack.ServiceManager.PlayerEngine.CurrentTrack;

            if (track == null)
            {
                return(null);
            }

            Socket stream_socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);

            Contact contact = ContactTrackInfo.From(track).Contact;

            if (contact != null)
            {
                DispatchManager dm = contact.DispatchManager;

                StreamActivity activity = dm.Get <StreamActivity> (contact, StreamingServer.ServiceName);
                if (activity != null)
                {
                    stream_socket.Connect(new UnixEndPoint(activity.Address));
                }
            }

            return(stream_socket);
        }
        private void CleanUpIfClosed(uint target_handle, object key)
        {
            if (target_handle < 1)
            {
                throw new ArgumentException("target_handle should be > 0");
            }
            else if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            Contact         contact = Connection.Roster.GetContact(target_handle);
            DispatchManager dm      = contact.DispatchManager;

            Dispatchable d = dm.Get(contact, key, DispatchObject);

            if (d != null)
            {
                if (d.IsClosed)
                {
                    dm.Remove(contact, key, DispatchObject);
                }
                else
                {
                    throw new InvalidOperationException(String.Format("{0} already has dispatchable object type {1} with key {2}",
                                                                      contact.Name, DispatchObject.FullName, key)
                                                        );
                }
            }
        }
        private void EnsureDBusActivity()
        {
            if (Contact == null)
            {
                return;
            }

            if (CurrentActivity == null)
            {
                DispatchManager dm = Contact.DispatchManager;
                CurrentActivity = dm.Get <DBusActivity> (Contact, MetadataProviderService.BusName);
            }
        }