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 | ||
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 | ||
21 | /** | |
22 | * Response to a "create session" command | |
23 | * | |
24 | * @author Matthew Khouzam | |
25 | * @since 3.0 | |
26 | */ | |
27 | public class CreateSessionResponse implements IRelayResponse { | |
28 | ||
29 | /** | |
30 | * Response size | |
31 | */ | |
32 | public static final int SIZE = Integer.SIZE / 8; | |
33 | ||
34 | /** enum lttng_viewer_create_session_return_code */ | |
35 | private final CreateSessionReturnCode fStatus; | |
36 | ||
37 | /** | |
38 | * Create session response network constructor | |
39 | * | |
40 | * @param inNet | |
41 | * network input stream | |
42 | * @throws IOException | |
43 | * network error | |
44 | */ | |
45 | public CreateSessionResponse(DataInputStream inNet) throws IOException { | |
46 | byte[] data = new byte[SIZE]; | |
47 | inNet.readFully(data); | |
48 | ByteBuffer bb = ByteBuffer.wrap(data); | |
49 | bb.order(ByteOrder.BIG_ENDIAN); | |
50 | fStatus = (CreateSessionReturnCode.values()[bb.getInt() - 1]); | |
51 | } | |
52 | ||
53 | /** | |
54 | * Get status | |
55 | * | |
56 | * @return the status | |
57 | */ | |
58 | public CreateSessionReturnCode getStatus() { | |
59 | return fStatus; | |
60 | } | |
61 | ||
62 | } |