gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / relayd / lttngviewerCommands / ListSessionsResponse.java
1 /**********************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial implementation and API
11 * Marc-Andre Laperle - Initial implementation and API
12 **********************************************************************/
13
14 package org.eclipse.linuxtools.internal.lttng2.control.core.relayd.lttngviewerCommands;
15
16 import java.io.DataInputStream;
17 import java.io.IOException;
18 import java.nio.ByteBuffer;
19 import java.nio.ByteOrder;
20 import java.util.List;
21
22 import com.google.common.collect.ImmutableList;
23 import com.google.common.collect.ImmutableList.Builder;
24
25 /**
26 * VIEWER_LIST_SESSIONS payload.
27 *
28 * @author Matthew Khouzam
29 * @since 3.0
30 */
31 public class ListSessionsResponse implements IRelayResponse {
32
33 /**
34 * Response size (nbSessions)
35 */
36 public static final int PACKET_FIXED_SIZE = Integer.SIZE / 8;
37
38 /** the list of sessions */
39 private final List<SessionResponse> fSessionList;
40
41 /**
42 * List Sessions response from network
43 *
44 * @param inNet
45 * the network stream
46 * @throws IOException
47 * network error
48 */
49 public ListSessionsResponse(DataInputStream inNet) throws IOException {
50 byte[] data = new byte[PACKET_FIXED_SIZE];
51 inNet.readFully(data);
52 ByteBuffer bb = ByteBuffer.wrap(data);
53 bb.order(ByteOrder.BIG_ENDIAN);
54 int nbSessions = bb.getInt();
55 Builder<SessionResponse> sl = new ImmutableList.Builder<>();
56 for (int session = 0; session < nbSessions; session++) {
57 sl.add(new SessionResponse(inNet));
58 }
59 fSessionList = sl.build();
60 }
61
62 /**
63 * Gets the session list
64 *
65 * @return the sessions list
66 */
67 public List<SessionResponse> getSessionsList() {
68 return fSessionList;
69 }
70
71
72 }
This page took 0.032048 seconds and 5 git commands to generate.