예제 #1
0
파일: player.go 프로젝트: xfanity/pulsar
func NewBTPlayer(bts *BTService, uri string, deleteAfter bool) *BTPlayer {
	btp := &BTPlayer{
		bts:                  bts,
		uri:                  uri,
		log:                  logging.MustGetLogger("btplayer"),
		deleteAfter:          deleteAfter,
		closing:              make(chan interface{}),
		bufferEvents:         broadcast.NewBroadcaster(),
		bufferPiecesProgress: map[int]float64{},
	}
	return btp
}
예제 #2
0
파일: service.go 프로젝트: xfanity/pulsar
func NewBTService(config BTConfiguration) *BTService {
	s := &BTService{
		Session:           libtorrent.NewSession(),
		log:               logging.MustGetLogger("btservice"),
		libtorrentLog:     logging.MustGetLogger("libtorrent"),
		alertsBroadcaster: broadcast.NewBroadcaster(),
		config:            &config,
		closing:           make(chan interface{}),
	}

	s.configure()
	go s.alertsConsumer()
	go s.logAlerts()
	go s.internetMonitor()

	return s
}
예제 #3
0
파일: torrentfs.go 프로젝트: xfanity/pulsar
func NewTorrentFile(file *os.File, tfs *TorrentFS, torrentHandle libtorrent.Torrent_handle, torrentInfo libtorrent.Torrent_info, fileEntry libtorrent.File_entry, fileEntryIdx int) (*TorrentFile, error) {
	tf := &TorrentFile{
		File:          file,
		tfs:           tfs,
		torrentHandle: torrentHandle,
		torrentInfo:   torrentInfo,
		fileEntry:     fileEntry,
		fileEntryIdx:  fileEntryIdx,
		pieceLength:   torrentInfo.Piece_length(),
		fileOffset:    fileEntry.GetOffset(),
		fileSize:      fileEntry.GetSize(),
		removed:       broadcast.NewBroadcaster(),
	}
	go tf.consumeAlerts()

	return tf, nil
}