blob: ad7e5ee8c095192a37ede9531ae740fa96d79e53 [file] [log] [blame]
Thomas Vachuska3553b302015-03-07 14:49:43 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska3553b302015-03-07 14:49:43 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.ui;
17
18import com.fasterxml.jackson.databind.node.ObjectNode;
Thomas Vachuska92b016b2016-05-20 11:37:57 -070019import org.onosproject.ui.model.topo.UiTopoLayout;
Thomas Vachuska3553b302015-03-07 14:49:43 -080020
21/**
22 * Abstraction of a user interface session connection.
23 */
24public interface UiConnection {
25
26 /**
Thomas Vachuska0af26912016-03-21 21:37:30 -070027 * Returns the name of the logged-in user for which this connection exists.
28 *
29 * @return logged in user name
30 */
31 String userName();
32
33 /**
Thomas Vachuska92b016b2016-05-20 11:37:57 -070034 * Returns the current layout context.
35 *
36 * @return current topology layout
37 */
38 UiTopoLayout currentLayout();
39
40 /**
41 * Changes the current layout context to the specified layout.
42 *
43 * @param topoLayout new topology layout context
44 */
45 void setCurrentLayout(UiTopoLayout topoLayout);
46
47 /**
48 * Returns the current view identifier.
49 *
50 * @return current view
51 */
52 String currentView();
53
54 /**
55 * Sets the currently selected view.
56 *
57 * @param viewId view identifier
58 */
59 void setCurrentView(String viewId);
60
61 /**
Thomas Vachuska3553b302015-03-07 14:49:43 -080062 * Sends the specified JSON message to the user interface client.
Simon Huntc5368182017-01-10 13:32:04 -080063 * It is assumed that the message is already correctly formatted and
64 * ready to send.
Thomas Vachuska3553b302015-03-07 14:49:43 -080065 *
66 * @param message message to send
67 */
68 void sendMessage(ObjectNode message);
69
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -070070 /**
71 * Composes a message into JSON and sends it to the user interface client.
72 *
Simon Huntc5368182017-01-10 13:32:04 -080073 * @param type message (event) type
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -070074 * @param payload message payload
75 */
Simon Huntc5368182017-01-10 13:32:04 -080076 void sendMessage(String type, ObjectNode payload);
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -070077
Thomas Vachuska3553b302015-03-07 14:49:43 -080078}