Commit | Line | Data |
---|---|---|
8e15b929 MK |
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 | ||
41b4bff4 | 14 | package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands; |
8e15b929 MK |
15 | |
16 | import java.io.DataInputStream; | |
17 | import java.io.IOException; | |
18 | import java.nio.ByteBuffer; | |
19 | import java.nio.ByteOrder; | |
20 | ||
21 | /** | |
22 | * Response to a "create session" command | |
23 | * | |
24 | * @author Matthew Khouzam | |
8e15b929 MK |
25 | */ |
26 | public class CreateSessionResponse implements IRelayResponse { | |
27 | ||
28 | /** | |
8adfbb73 | 29 | * Response size (fStatus) |
8e15b929 MK |
30 | */ |
31 | public static final int SIZE = Integer.SIZE / 8; | |
32 | ||
33 | /** enum lttng_viewer_create_session_return_code */ | |
34 | private final CreateSessionReturnCode fStatus; | |
35 | ||
36 | /** | |
37 | * Create session response network constructor | |
38 | * | |
39 | * @param inNet | |
40 | * network input stream | |
41 | * @throws IOException | |
42 | * network error | |
43 | */ | |
44 | public CreateSessionResponse(DataInputStream inNet) throws IOException { | |
45 | byte[] data = new byte[SIZE]; | |
46 | inNet.readFully(data); | |
47 | ByteBuffer bb = ByteBuffer.wrap(data); | |
48 | bb.order(ByteOrder.BIG_ENDIAN); | |
49 | fStatus = (CreateSessionReturnCode.values()[bb.getInt() - 1]); | |
50 | } | |
51 | ||
52 | /** | |
53 | * Get status | |
54 | * | |
55 | * @return the status | |
56 | */ | |
57 | public CreateSessionReturnCode getStatus() { | |
58 | return fStatus; | |
59 | } | |
60 | ||
61 | } |