2017-01-20 01:59:18 +00:00
|
|
|
use byteorder::{BigEndian, WriteBytesExt};
|
2016-03-13 20:03:40 +00:00
|
|
|
use std::io::Write;
|
|
|
|
|
2017-08-03 18:58:44 +00:00
|
|
|
use core::channel::ChannelData;
|
|
|
|
use core::session::Session;
|
2018-02-12 20:02:27 +00:00
|
|
|
use core::spotify_id::FileId;
|
2016-05-09 11:22:51 +00:00
|
|
|
|
2017-01-20 01:59:18 +00:00
|
|
|
pub fn get(session: &Session, file: FileId) -> ChannelData {
|
|
|
|
let (channel_id, channel) = session.channel().allocate();
|
|
|
|
let (_headers, data) = channel.split();
|
2016-05-09 11:22:51 +00:00
|
|
|
|
2017-01-20 01:59:18 +00:00
|
|
|
let mut packet: Vec<u8> = Vec::new();
|
|
|
|
packet.write_u16::<BigEndian>(channel_id).unwrap();
|
|
|
|
packet.write_u16::<BigEndian>(0).unwrap();
|
|
|
|
packet.write(&file.0).unwrap();
|
|
|
|
session.send_packet(0x19, packet);
|
2016-05-09 11:22:51 +00:00
|
|
|
|
2017-01-20 01:59:18 +00:00
|
|
|
data
|
2016-03-13 20:03:40 +00:00
|
|
|
}
|