DeviceImpl.java
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.socketio.SocketIONamespace
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
*/
package com.adobe.cq.screens.sessions.impl;
import com.adobe.cq.screens.sessions.Device;
import com.adobe.cq.screens.sessions.Display;
import com.adobe.cq.screens.sessions.ScreensSession;
import com.adobe.cq.screens.sessions.impl.DisplayImpl;
import com.adobe.cq.screens.sessions.impl.ScreensSessionImpl;
import com.adobe.granite.socketio.SocketIONamespace;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
public class DeviceImpl
implements Device {
private final String id;
private final DisplayImpl screen;
private int width;
private int height;
private boolean autoRegistered;
public DeviceImpl(String id, DisplayImpl screen) {
this.id = id;
this.screen = screen;
}
@Override
public String getId() {
return this.id;
}
@Override
public Display getDisplay() {
return this.screen;
}
@Override
public int getWidth() {
return this.width;
}
public void setWidth(int width) {
this.width = width;
}
@Override
public int getHeight() {
return this.height;
}
public void setHeight(int height) {
this.height = height;
}
public boolean isAutoRegistered() {
return this.autoRegistered;
}
public void setAutoRegistered(boolean autoRegistered) {
this.autoRegistered = autoRegistered;
}
public ScreensSessionImpl connect(SocketIONamespace nsp) {
ScreensSessionImpl session = this.screen.getOrCreateSession(nsp);
session.connect(this);
return session;
}
public boolean isConnected() {
ScreensSessionImpl session = (ScreensSessionImpl)this.screen.getSession();
return session != null && session.isConnected(this);
}
public void disconnect() {
ScreensSessionImpl session = (ScreensSessionImpl)this.screen.getSession();
if (session != null) {
session.disconnect(this);
}
}
@Override
public JSONObject toJSON() {
try {
JSONObject obj = new JSONObject();
obj.put("id", (Object)this.id);
obj.put("w", this.width);
obj.put("h", this.height);
return obj;
}
catch (JSONException e) {
throw new IllegalStateException((Throwable)e);
}
}
}