use of com.serotonin.m2m2.web.dwr.longPoll.LongPollData in project ma-core-public by infiniteautomation.
the class BaseDwr method initializeLongPoll.
@DwrPermission(anonymous = true)
public Map<String, Object> initializeLongPoll(int pollSessionId, LongPollRequest request) {
LongPollData data = getLongPollData(pollSessionId, true);
data.setRequest(request);
return doLongPoll(pollSessionId);
}
use of com.serotonin.m2m2.web.dwr.longPoll.LongPollData in project ma-modules-public by infiniteautomation.
the class WatchListDwr method resetWatchListState.
@DwrPermission(anonymous = true)
public void resetWatchListState(int pollSessionId) {
LongPollData data = getLongPollData(pollSessionId, false);
synchronized (data.getState()) {
WatchListCommon.getWatchListStates(data).clear();
WatchListVO wl = getWatchList();
for (DataPointVO dp : wl.getPointList()) dp.resetLastValue();
}
notifyLongPollImpl(data.getRequest());
}
use of com.serotonin.m2m2.web.dwr.longPoll.LongPollData in project ma-modules-public by infiniteautomation.
the class GraphicalViewLongPollDefinition method handleLongPoll.
@Override
public void handleLongPoll(LongPollData data, Map<String, Object> response, User user) {
boolean view = false;
boolean viewEdit = false;
boolean anon = false;
if (data.getRequest().hasHandler("graphicalView") && user != null)
view = true;
else if (data.getRequest().hasHandler("graphicalViewEdit") && user != null)
viewEdit = true;
else if (data.getRequest().hasHandler("graphicalViewAnon"))
anon = true;
if (view || viewEdit || anon) {
LongPollState state = data.getState();
List<ViewComponentState> graphicalViewStates = GraphicalViewsCommon.getGraphicalViewListStates(data);
List<ViewComponentState> newStates;
synchronized (state) {
if (anon)
newStates = graphicalViewDwr.getViewPointDataAnon(data.getRequest().getRefId());
else
newStates = graphicalViewDwr.getViewPointData(viewEdit);
List<ViewComponentState> differentStates = new ArrayList<ViewComponentState>();
for (ViewComponentState newState : newStates) {
ViewComponentState oldState = getGraphicalViewState(newState.getId(), graphicalViewStates);
if (oldState == null)
differentStates.add(newState);
else {
ViewComponentState copy = newState.clone();
copy.removeEqualValue(oldState);
if (!copy.isEmpty())
differentStates.add(copy);
}
}
if (!differentStates.isEmpty()) {
response.put("viewStates", differentStates);
GraphicalViewsCommon.setGraphicalViewListStates(data, newStates);
}
}
}
}
use of com.serotonin.m2m2.web.dwr.longPoll.LongPollData in project ma-modules-public by infiniteautomation.
the class WatchListLongPollHandler method handleLongPoll.
@Override
public void handleLongPoll(LongPollData data, Map<String, Object> response, User user) {
if (data.getRequest().hasHandler(key) && user != null) {
LongPollState state = data.getState();
List<WatchListState> watchListStates = WatchListCommon.getWatchListStates(data);
synchronized (state) {
List<WatchListState> newStates = watchListDwr.getPointData();
List<WatchListState> differentStates = new ArrayList<WatchListState>();
for (WatchListState newState : newStates) {
WatchListState oldState = getWatchListState(newState.getId(), watchListStates);
if (oldState == null)
differentStates.add(newState);
else {
WatchListState copy = newState.clone();
copy.removeEqualValue(oldState);
if (!copy.isEmpty())
differentStates.add(copy);
}
}
if (!differentStates.isEmpty()) {
response.put("watchListStates", differentStates);
state.setAttribute("watchListStates", newStates);
}
}
}
}
use of com.serotonin.m2m2.web.dwr.longPoll.LongPollData in project ma-core-public by infiniteautomation.
the class BaseDwr method getLongPollData.
protected LongPollData getLongPollData(int pollSessionId, boolean refreshState) {
List<LongPollData> dataList = getLongPollData();
LongPollData data = getDataFromList(dataList, pollSessionId);
if (data == null) {
synchronized (dataList) {
data = getDataFromList(dataList, pollSessionId);
if (data == null) {
data = new LongPollData(pollSessionId);
refreshState = true;
dataList.add(data);
}
}
}
if (refreshState)
data.setState(new LongPollState());
return data;
}
Aggregations