Package se.despotify.client.protocol.channel

Examples of se.despotify.client.protocol.channel.ChannelCallback


        user.getId(),
        collaborative ? 1 : 0
    );

    /* Create channel callback */
    ChannelCallback callback = new ChannelCallback();


    /* Create channel and buffer. */
    Channel channel = new Channel("Create-Playlist-Channel", Channel.Type.TYPE_PLAYLIST, callback);
    byte[] xmlBytes = xml.getBytes();
    ByteBuffer buffer = ByteBuffer.allocate(2 + 17 + 4 + 4 + 4 + 1 + 1 + xmlBytes.length);

    /* Append channel id, playlist id and some bytes... */
    buffer.putShort((short) channel.getId());
    buffer.put(requestedPlaylistUUID);
    buffer.put((byte) 0x02); // uuid playlist marker?
    buffer.putInt(0); // playlist revision?
    buffer.putInt(0); // playlist tracks size?
    buffer.putInt(-1); // playlist checksum? -1 when create uuid
    buffer.put((byte) 0x01); // normally means collaborate, not sure whats with this here
    buffer.put((byte) 0x03); // unknown
    buffer.put(xmlBytes);
    buffer.flip();

    /* Register channel. */
    Channel.register(channel);

    /* Send packet. */
    ManagedConnection connection = connectionManager.getManagedConnection();
    connection.getProtocol().sendPacket(PacketType.changePlaylist, buffer, "create playlist UUID");

    /* Get response. */
    byte[] data = callback.getData("create playlist uuid reponse");
    connection.close();

    xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<playlist>\n" +
        new String(data, Charset.forName("UTF-8")) +
        "\n</playlist>";
View Full Code Here


  public Boolean send(DespotifyManager connectionManager) throws DespotifyException {
    byte[] data;


    /* Create channel callback */
    ChannelCallback callback = new ChannelCallback();

    /* Create channel and buffer. */
    Channel channel = new Channel("Playlist-Channel", Channel.Type.TYPE_PLAYLIST, callback);
    ByteBuffer buffer = ByteBuffer.allocate(2 + 16 + 1 + 4 + 4 + 4 + 1);

    /* Append channel id, playlist id and some bytes... */
    buffer.putShort((short) channel.getId());
    buffer.put(playlist.getByteUUID()); /// playlist UUID
    buffer.put((byte) 0x02); // playlist UUID type

    // todo if getTracks() == null..
    buffer.putInt(-1); // playlist history. -1: current. 0: changes since version 0, 1: since version 1, etc.

    buffer.putInt(0); // unknown
    buffer.putInt(-1); // checksum?
    buffer.put((byte) 0x01);
    buffer.flip();
    /* Register channel. */
    Channel.register(channel);

    /* Send packet. */
    ManagedConnection connection = connectionManager.getManagedConnection();
    connection.getProtocol().sendPacket(PacketType.getPlaylist, buffer, "get playlist");

    /* Get data and inflate it. */
    data = callback.getData("get playlist response");
    connection.close();
   
    if (data.length == 0) {
      throw new ReceivedEmptyResponseException();
    }
View Full Code Here

TOP

Related Classes of se.despotify.client.protocol.channel.ChannelCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.