Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.ui; |
| 17 | |
| 18 | import com.fasterxml.jackson.databind.node.ObjectNode; |
Thomas Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 19 | import org.onosproject.ui.model.topo.UiTopoLayout; |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Abstraction of a user interface session connection. |
| 23 | */ |
| 24 | public interface UiConnection { |
| 25 | |
| 26 | /** |
Thomas Vachuska | 0af2691 | 2016-03-21 21:37:30 -0700 | [diff] [blame] | 27 | * 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 Vachuska | 92b016b | 2016-05-20 11:37:57 -0700 | [diff] [blame] | 34 | * 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 Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 62 | * Sends the specified JSON message to the user interface client. |
Simon Hunt | c536818 | 2017-01-10 13:32:04 -0800 | [diff] [blame] | 63 | * It is assumed that the message is already correctly formatted and |
| 64 | * ready to send. |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 65 | * |
| 66 | * @param message message to send |
| 67 | */ |
| 68 | void sendMessage(ObjectNode message); |
| 69 | |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 70 | /** |
| 71 | * Composes a message into JSON and sends it to the user interface client. |
| 72 | * |
Simon Hunt | c536818 | 2017-01-10 13:32:04 -0800 | [diff] [blame] | 73 | * @param type message (event) type |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 74 | * @param payload message payload |
| 75 | */ |
Simon Hunt | c536818 | 2017-01-10 13:32:04 -0800 | [diff] [blame] | 76 | void sendMessage(String type, ObjectNode payload); |
Thomas Vachuska | b6acc7b | 2015-03-11 09:11:21 -0700 | [diff] [blame] | 77 | |
Thomas Vachuska | 3553b30 | 2015-03-07 14:49:43 -0800 | [diff] [blame] | 78 | } |