Here are the examples of the java api com.iris.client.ClientRequest taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
75 Examples
19
Source : NettyIrisClient2.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private ClientFuture<ClientEvent> restfulRequest(ClientRequest clientRequest) {
NettyHttpRequest.Builder builder = restfulRequestBuilder(clientRequest);
HttpResponseHandler handler = new HttpResponseHandler();
sendHttpRequest(builder).onCompletion(handler);
return handler;
}
19
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void setExitDelayOnSec(int exitDelayOnSec) {
ClientRequest request = setAttributes(SecuritySubsystem.ALARMMODE_ON, SecurityAlarmMode.ATTR_EXITDELAYSEC, exitDelayOnSec);
sendRequest(request);
}
19
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void setEntranceDelayOnSec(int entranceDelayOnSec) {
ClientRequest request = setAttributes(SecuritySubsystem.ALARMMODE_ON, SecurityAlarmMode.ATTR_ENTRANCEDELAYSEC, entranceDelayOnSec);
sendRequest(request);
}
19
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void setEntranceDelayPartialSec(int entranceDelayPartialSec) {
ClientRequest request = setAttributes(SecuritySubsystem.ALARMMODE_PARTIAL, SecurityAlarmMode.ATTR_ENTRANCEDELAYSEC, entranceDelayPartialSec);
sendRequest(request);
}
19
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void setSilentAlarm(boolean silentAlarm) {
ClientRequest request = setAttributes(SecurityAlarmMode.ATTR_SILENT, silentAlarm);
sendRequest(request);
}
19
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void setExitDelayPartialSec(int exitDelayPartialSec) {
ClientRequest request = setAttributes(SecuritySubsystem.ALARMMODE_PARTIAL, SecurityAlarmMode.ATTR_EXITDELAYSEC, exitDelayPartialSec);
sendRequest(request);
}
19
Source : PPARemovalController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void callPlatformForSessionBootedEvent(ClientRequest request) {
loggedOutListener = CorneaClientFactory.getClient().addMessageListener(Listeners.runOnUiThread(new Listener<ClientMessage>() {
@Override
public void onEvent(ClientMessage clientMessage) {
if (!(clientMessage.getEvent() instanceof Capability.DeletedEvent)) {
return;
}
Capability.DeletedEvent deletedEvent = new Capability.DeletedEvent(clientMessage.getEvent());
boolean bootSession = Boolean.TRUE.equals(deletedEvent.getAttribute("bootSession"));
boolean accountDeleted = String.valueOf(clientMessage.getSource()).startsWith(Addresses.toServiceAddress(Account.NAMESPACE));
if (bootSession || accountDeleted) {
if (removedCallback != null) {
removedCallback.onSuccess();
// Clear this since we're going to cirreplacedventing the listeners in the request.
removedCallback = null;
}
Listeners.clear(loggedOutListener);
}
}
}));
callPlatform(request);
}
19
Source : MockClientTestCase.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public MockClient.ClientResponseBuilder expectRequest(ClientRequest request) {
return client().expectRequest(request);
}
19
Source : DeviceRemovalController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void callPlatform(ClientRequest request) {
client.request(request).onSuccess(successListener).onFailure(removalFailureListener);
}
19
Source : DeviceRemovalController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void callPlatformWithoutSuccessHandler(ClientRequest request) {
client.request(request).onFailure(removalFailureListener);
}
18
Source : BaseService.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected <V> ClientFuture<V> request(ClientRequest request, final Transform<V> t) {
final SettableClientFuture<V> future = new SettableClientFuture<V>();
getClient().request(request).onSuccess(new Listener<ClientEvent>() {
@Override
public void onEvent(ClientEvent event) {
try {
if (event == null || EmptyEvent.NAME.equals(event.getType())) {
future.setValue(null);
} else if (ErrorEvent.NAME.equals(event.getType())) {
future.setError(new ErrorResponseException((String) event.getAttribute("code"), (String) event.getAttribute("message")));
} else {
future.setValue(t.transform(event));
}
} catch (Exception e) {
future.setError(e);
}
}
}).onFailure(new Listener<Throwable>() {
@Override
public void onEvent(Throwable error) {
future.setError(error);
}
});
return future;
}
18
Source : BaseModel.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/* (non-Javadoc)
* @see com.iris.client.model.Model#request(com.iris.client.ClientRequest)
*/
@Override
public ClientFuture<ClientEvent> request(ClientRequest request) {
request.setAddress(getAddress());
if (request.getTimeoutMs() <= 0) {
request.setTimeoutMs(DEFAULT_TIMEOUT_MS);
}
return getClient().request(request);
}
18
Source : PersonServiceImpl.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/* (non-Javadoc)
* @see com.iris.client.service.PersonService#sendPreplacedwordReset(java.lang.String, java.lang.String)
*/
@Override
public ClientFuture<SendPreplacedwordResetResponse> sendPreplacedwordReset(String email, String method) {
ClientRequest request = buildRequest(PersonService.CMD_SENDPreplacedWORDRESET, ImmutableMap.<String, Object>of(SendPreplacedwordResetRequest.ATTR_EMAIL, email, SendPreplacedwordResetRequest.ATTR_METHOD, method));
ClientFuture<ClientEvent> result = client.request(request);
return Futures.transform(result, new Function<ClientEvent, SendPreplacedwordResetResponse>() {
@Override
public SendPreplacedwordResetResponse apply(ClientEvent input) {
return new SendPreplacedwordResetResponse(input);
}
});
}
18
Source : PersonServiceImpl.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
// TODO move down to BaseServiceImpl
protected ClientRequest buildRequest(String commandName, Map<String, Object> attributes) {
ClientRequest request = new ClientRequest();
request.setCommand(commandName);
request.setAttributes(attributes);
return defaults(request);
}
18
Source : NettyIrisClient2.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public ClientFuture<ClientEvent> request(ClientRequest clientRequest) {
if (clientRequest.isRestfulRequest()) {
return restfulRequest(clientRequest);
} else {
return websocketRequest(clientRequest);
}
}
18
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void sendRequest(ClientRequest request) {
SubsystemModel model = getModel();
if (model == null) {
logger.warn("Unable to send request [{}] because model is not yet loaded", request);
return;
}
model.request(request).onFailure(onFailure);
}
18
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void setEnableSounds(boolean enableSounds) {
ClientRequest request = setAttributes(SecurityAlarmMode.ATTR_SOUNDSENABLED, enableSounds);
sendRequest(request);
}
18
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/**
* Sets the alarm sensitivity for both ON and PARTIAL modes
* @param alarmSensitivity
*/
public void setAlarmSensitivity(int alarmSensitivity) {
ClientRequest request = setAttributes(SecurityAlarmMode.ATTR_ALARMSENSITIVITYDEVICECOUNT, alarmSensitivity);
sendRequest(request);
}
18
Source : HubDeviceModelDTO.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public ClientFuture<ClientEvent> request(ClientRequest clientRequest) {
return delegate.request(clientRequest);
}
18
Source : MockDeviceModel.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public ClientFuture<ClientEvent> request(ClientRequest clientRequest) {
return null;
}
18
Source : MockClient.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public void submit(ClientRequest clientRequest) {
fireSent(clientRequest);
for (Expectation<ClientRequest, Void> expectation : submitExpectations) {
if (expectation.matches(clientRequest)) {
try {
expectation.invoke(clientRequest);
return;
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable t) {
throw new UncheckedExecutionException(t);
}
}
}
}
18
Source : MockClient.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public ClientResponseBuilder expectRequest(ClientRequest request) {
return expectRequest(Predicates.equalTo(request));
}
18
Source : MockClient.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void fireSent(ClientRequest request) {
requestListeners.fireEvent(request);
}
18
Source : MockClient.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public ClientFuture<ClientEvent> request(ClientRequest clientRequest) {
fireSent(clientRequest);
for (Expectation<ClientRequest, ClientFuture<ClientEvent>> expectation : requestExpectations) {
if (expectation.matches(clientRequest)) {
try {
return expectation.invoke(clientRequest);
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable t) {
throw new UncheckedExecutionException(t);
}
}
}
throw new IllegalStateException("No response for request " + clientRequest);
}
18
Source : FanFragment.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private void doRequest(ClientRequest request) {
if (!CorneaClientFactory.isConnected()) {
return;
}
CorneaClientFactory.getClient().request(request).onFailure(updateFailure);
}
17
Source : BaseService.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected ClientFuture<ClientEvent> request(String command, Map<String, Object> attributes) {
ClientRequest request = new ClientRequest();
request.setAddress(getAddress());
request.setAttributes(attributes);
return getClient().request(request);
}
17
Source : BaseModel.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public ClientFuture<ClientEvent> request(String command, Map<String, Object> attributes, boolean restful) {
ClientRequest request = new ClientRequest();
request.setCommand(command);
request.setAddress(getAddress());
request.setAttributes(attributes);
request.setTimeoutMs(DEFAULT_TIMEOUT_MS);
request.setRestfulRequest(restful);
return getClient().request(request);
}
17
Source : RuleServiceImpl.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
// TODO move down to BaseServiceImpl
protected ClientRequest buildRequest(String commandName, Map<String, Object> attributes) {
ClientRequest request = new ClientRequest();
request.setCommand(commandName);
request.setAddress(getAddress());
request.setAttributes(attributes);
request.setRestfulRequest(false);
request.setTimeoutMs(30000);
return request;
}
17
Source : RuleServiceImpl.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public ClientFuture<GetCategoriesResponse> getCategories(String placeId) {
ClientRequest request = buildRequest(RuleService.CMD_GETCATEGORIES, ImmutableMap.<String, Object>of(GetCategoriesRequest.ATTR_PLACEID, placeId));
ClientFuture<ClientEvent> result = client.request(request);
return Futures.transform(result, new Function<ClientEvent, GetCategoriesResponse>() {
@Override
public GetCategoriesResponse apply(ClientEvent input) {
return new GetCategoriesResponse(input);
}
});
}
17
Source : RuleServiceImpl.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/* (non-Javadoc)
* @see com.iris.client.service.RuleService#listRuleTemplates(java.lang.String)
*/
@Override
public ClientFuture<ListRuleTemplatesResponse> listRuleTemplates(String placeId) {
ClientRequest request = buildRequest(RuleService.CMD_LISTRULETEMPLATES, ImmutableMap.<String, Object>of(ListRuleTemplatesRequest.ATTR_PLACEID, placeId));
ClientFuture<ClientEvent> result = client.request(request);
return Futures.transform(result, new Function<ClientEvent, ListRuleTemplatesResponse>() {
@Override
public ListRuleTemplatesResponse apply(ClientEvent input) {
ListRuleTemplatesResponse response = new ListRuleTemplatesResponse(input);
IrisClientFactory.getModelCache().retainAll(RuleTemplate.NAMESPACE, response.getRuleTemplates());
return response;
}
});
}
17
Source : PersonServiceImpl.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/* (non-Javadoc)
* @see com.iris.client.service.PersonService#resetPreplacedword(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public ClientFuture<ResetPreplacedwordResponse> resetPreplacedword(String email, String token, String preplacedword) {
ClientRequest request = buildRequest(PersonService.CMD_RESETPreplacedWORD, ImmutableMap.<String, Object>of(ResetPreplacedwordRequest.ATTR_EMAIL, email, ResetPreplacedwordRequest.ATTR_TOKEN, token, ResetPreplacedwordRequest.ATTR_PreplacedWORD, preplacedword));
ClientFuture<ClientEvent> result = client.request(request);
return Futures.transform(result, new Function<ClientEvent, ResetPreplacedwordResponse>() {
@Override
public ResetPreplacedwordResponse apply(ClientEvent input) {
return new ResetPreplacedwordResponse(input);
}
});
}
17
Source : NettyIrisClient2.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private void websocketSendMessage(ClientRequest request, ClientMessage message) {
// TODO
requestListeners.fireEvent(request);
String payload = ClientMessageSerializer.serialize(message);
getClient().fire(payload);
logger.debug("Request Sent To Platform: {}", payload);
}
17
Source : DebouncedClientRequest.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public clreplaced DebouncedClientRequest extends TimerTask {
private final IrisClient irisClient;
private final ClientRequest request;
private Listener<Throwable> onError;
private Listener<ClientEvent> onSuccess;
private Listener<Result<ClientEvent>> onCompletion;
public DebouncedClientRequest(@NonNull IrisClient client, @NonNull ClientRequest request) {
Preconditions.checkNotNull(client);
Preconditions.checkNotNull(request);
this.irisClient = client;
this.request = request;
}
public void setOnError(Listener<Throwable> onError) {
this.onError = onError;
}
public void setOnSuccess(Listener<ClientEvent> onSuccess) {
this.onSuccess = onSuccess;
}
@Override
public void run() {
ClientFuture<ClientEvent> requestFuture = irisClient.request(request);
if (onError != null) {
requestFuture.onFailure(onError);
}
if (onSuccess != null) {
requestFuture.onSuccess(onSuccess);
}
}
}
17
Source : ScheduleEditController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private ClientFuture<ClientEvent> add(ScheduledSetPoint setPoint) {
ClientRequest request = new ClientRequest();
request.setAddress(schedulerAddress);
request.setCommand(WeeklySchedule.ScheduleWeeklyCommandRequest.NAME + ":" + setPoint.getMode().name());
request.setAttribute(WeeklySchedule.ScheduleWeeklyCommandRequest.ATTR_DAYS, serializeDays(setPoint));
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_MODE, setPoint.getTimeOfDay().getSunriseSunset().name());
if (SunriseSunset.ABSOLUTE.equals(setPoint.getTimeOfDay().getSunriseSunset())) {
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_TIME, setPoint.getTimeOfDay().toString());
} else {
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_OFFSETMINUTES, setPoint.getTimeOfDay().getOffset());
}
request.setAttribute(WeeklySchedule.ScheduleWeeklyCommandRequest.ATTR_ATTRIBUTES, serializeAttributes(setPoint));
return CorneaClientFactory.getClient().request(request).onFailure(onError);
}
17
Source : PPARemovalController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void callPlatform(ClientRequest request) {
try {
CorneaClientFactory.getClient().request(request).onFailure(Listeners.runOnUiThread(new Listener<Throwable>() {
@Override
public void onEvent(Throwable throwable) {
if (removedCallback != null) {
removedCallback.onError(throwable);
}
Listeners.clear(loggedOutListener);
}
})).onSuccess(Listeners.runOnUiThread(new Listener<ClientEvent>() {
@Override
public void onEvent(ClientEvent clientEvent) {
if (removedCallback != null) {
removedCallback.onSuccess();
}
}
}));
} catch (Exception ex) {
if (removedCallback != null) {
removedCallback.onError(ex);
}
}
}
17
Source : ScheduleCommandEditController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private ClientFuture<ClientEvent> delete(String schedulerAddress, ScheduleCommandModel scheduleCommandModel) {
ClientRequest request = new ClientRequest();
request.setAddress(schedulerAddress);
request.setCommand(Schedule.DeleteCommandRequest.NAME + ":" + scheduleCommandModel.getSchedulerGroupId());
request.setAttribute(Schedule.DeleteCommandRequest.ATTR_COMMANDID, scheduleCommandModel.getId());
return CorneaClientFactory.getClient().request(request);
}
16
Source : RuleServiceImpl.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/* (non-Javadoc)
* @see com.iris.client.service.RuleService#listRules(java.lang.String)
*/
@Override
public ClientFuture<ListRulesResponse> listRules(String placeId) {
ClientRequest request = buildRequest(RuleService.CMD_LISTRULES, ImmutableMap.<String, Object>of(ListRulesRequest.ATTR_PLACEID, placeId));
ClientFuture<ClientEvent> result = client.request(request);
return Futures.transform(result, new Function<ClientEvent, ListRulesResponse>() {
@Override
public ListRulesResponse apply(ClientEvent input) {
ListRulesResponse response = new ListRulesResponse(input);
IrisClientFactory.getModelCache().retainAll(Rule.NAMESPACE, response.getRules());
return response;
}
});
}
16
Source : CachedModelSource.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected ClientFuture<M> doLoad() {
if (TextUtils.isEmpty(address)) {
this.request = Futures.failedFuture(new RuntimeException("Empty destination."));
} else {
ClientRequest request = new ClientRequest();
request.setAddress(address);
request.setCommand(Capability.CMD_GET_ATTRIBUTES);
request.setTimeoutMs(timeoutMs);
ClientFuture<ClientEvent> response = client.request(request);
this.request = Futures.transform(response, this);
}
return this.request;
}
16
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/**
* Sets an attribute on both PARTIAL and ON mode.
* @param attribute
* @param value
* @return
*/
protected ClientRequest setAttributes(String attribute, Object value) {
ClientRequest request = new ClientRequest();
request.setCommand(Capability.CMD_SET_ATTRIBUTES);
request.setAttribute(CapabilityInstances.getAttributeName(SecuritySubsystem.ALARMMODE_ON, attribute), value);
request.setAttribute(CapabilityInstances.getAttributeName(SecuritySubsystem.ALARMMODE_PARTIAL, attribute), value);
return request;
}
16
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected ClientRequest setAttributes(String instance, String attribute, Object value) {
ClientRequest request = new ClientRequest();
request.setCommand(Capability.CMD_SET_ATTRIBUTES);
request.setAttribute(CapabilityInstances.getAttributeName(instance, attribute), value);
return request;
}
16
Source : ScheduleEditController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private void deleteCommand() {
ClientRequest request = new ClientRequest();
request.setAddress(schedulerAddress);
request.setCommand(Schedule.DeleteCommandRequest.NAME + ":" + setPoint.getMode().name());
request.setAttribute(Schedule.DeleteCommandRequest.ATTR_COMMANDID, setPoint.getId());
CorneaClientFactory.getClient().request(request).onFailure(onError).onSuccess(onDone);
}
16
Source : ScheduleEditController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private ClientFuture<ClientEvent> update(ScheduledSetPoint setPoint) {
ClientRequest request = new ClientRequest();
request.setAddress(schedulerAddress);
request.setCommand(WeeklySchedule.UpdateWeeklyCommandRequest.NAME + ":" + setPoint.getMode().name());
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_DAYS, serializeDays(setPoint));
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_MODE, setPoint.getTimeOfDay().getSunriseSunset().name());
if (SunriseSunset.ABSOLUTE.equals(setPoint.getTimeOfDay().getSunriseSunset())) {
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_TIME, setPoint.getTimeOfDay().toString());
} else {
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_OFFSETMINUTES, setPoint.getTimeOfDay().getOffset());
}
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_ATTRIBUTES, serializeAttributes(setPoint));
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_COMMANDID, setPoint.getId());
return CorneaClientFactory.getClient().request(request).onFailure(onError);
}
16
Source : AlarmSoundsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void setSilentAlarm(final String alarmInstance, final boolean isSilent) {
ClientRequest request = new ClientRequest();
request.setCommand(Capability.CMD_SET_ATTRIBUTES);
request.setAttribute(CapabilityInstances.getAttributeName(alarmInstance, Alarm.ATTR_SILENT), isSilent);
getModel().request(request).onFailure(failureListener);
if (getCallback() != null) {
getCallback().onSilentAlarmChanged(alarmInstance, isSilent);
}
}
16
Source : LightAndSwitchController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void updateAttributeRequest(String key, Object value) {
DeviceModel model = getDevice();
if (model == null) {
onError(new RuntimeException("Model is MIA; Unable to fulfill request."));
return;
}
ClientRequest request = new ClientRequest();
request.setRestfulRequest(false);
request.setTimeoutMs(DEFAULT_TIMEOUT);
request.setAddress(model.getAddress());
request.setCommand(Capability.CMD_SET_ATTRIBUTES);
request.setAttribute(key, value);
DebouncedClientRequest debouncedRequest = new DebouncedClientRequest(irisClient, request);
debouncedRequest.setOnError(onErrorListener);
debouncedRequest.setOnSuccess(onSuccessListener);
debouncedRequestScheduler.schedule(model.getAddress(), debouncedRequest);
}
16
Source : ScheduleCommandEditController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private ClientFuture<ClientEvent> add(String schedulerAddress, String groupId, String messageType, Set<String> days, SunriseSunset mode, String time, Integer offset, Map<String, Object> attributes) {
ClientRequest request = new ClientRequest();
request.setAddress(schedulerAddress);
request.setCommand(WeeklySchedule.ScheduleWeeklyCommandRequest.NAME + ":" + groupId);
request.setAttribute(WeeklySchedule.ScheduleWeeklyCommandRequest.ATTR_MESSAGETYPE, messageType);
request.setAttribute(WeeklySchedule.ScheduleWeeklyCommandRequest.ATTR_DAYS, days);
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_MODE, mode.name());
if (SunriseSunset.ABSOLUTE.equals(mode)) {
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_TIME, time);
} else {
request.setAttribute(WeeklySchedule.UpdateWeeklyCommandRequest.ATTR_OFFSETMINUTES, offset);
}
request.setAttribute(WeeklySchedule.ScheduleWeeklyCommandRequest.ATTR_ATTRIBUTES, attributes);
return CorneaClientFactory.getClient().request(request);
}
16
Source : PlacesAndPeopleController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void getPeople(final PlaceAndRoleModel place) {
ClientRequest request = new ClientRequest();
request.setAddress(place.getAddress());
request.setCommand(Place.ListPersonsWithAccessRequest.NAME);
request.setRestfulRequest(false);
request.setTimeoutMs(30_000);
CorneaClientFactory.getClient().request(request).onFailure(errorListener).onSuccess(new Listener<ClientEvent>() {
@SuppressWarnings({ "unchecked" })
@Override
public void onEvent(ClientEvent event) {
Place.ListPersonsWithAccessResponse response = new Place.ListPersonsWithAccessResponse(event);
List<Map<String, Object>> descriptors = response.getPersons();
List<PersonModelProxy> people = new ArrayList<>(descriptors.size() + 1);
PersonModel loggedIn = SessionController.instance().getPerson();
for (Map<String, Object> descriptor : descriptors) {
PersonAccessDescriptor person = new PersonAccessDescriptor(descriptor);
boolean loggedInCurrently = loggedIn != null && loggedIn.getId().equals(person.getPerson().get(Person.ATTR_ID));
if (!loggedInCurrently) {
// So we don't show the 'viewer' (their info is under 'profile')
people.add(new PersonModelProxy(person.getPerson(), person.getRole()));
}
}
listInvitedPeople(place, people);
}
});
}
16
Source : PlacesAndPeopleController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void listInvitedPeople(final PlaceAndRoleModel place, final List<PersonModelProxy> existing) {
ClientRequest request = new ClientRequest();
request.setAddress(place.getAddress());
request.setCommand(Place.PendingInvitationsRequest.NAME);
request.setRestfulRequest(false);
request.setTimeoutMs(30_000);
CorneaClientFactory.getClient().request(request).onFailure(errorListener).onSuccess(new Listener<ClientEvent>() {
@Override
public void onEvent(ClientEvent clientEvent) {
Place.PendingInvitationsResponse response = new Place.PendingInvitationsResponse(clientEvent);
List<Map<String, Object>> invitations = response.getInvitations();
List<PersonModelProxy> people = new ArrayList<>(invitations.size() + existing.size() + 1);
for (Map<String, Object> item : invitations) {
people.add(PersonModelProxy.fromInvitation(item));
}
people.addAll(existing);
Collections.sort(people);
peoplePerPlaceMap.put(place, people);
addPersons(place, people);
getPeopleAtEachPlace();
}
});
}
15
Source : RuleServiceImpl.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public ClientFuture<GetRuleTemplatesByCategoryResponse> getRuleTemplatesByCategory(String placeId, String category) {
ClientRequest request = buildRequest(RuleService.CMD_GETRULETEMPLATESBYCATEGORY, ImmutableMap.<String, Object>of(GetRuleTemplatesByCategoryRequest.ATTR_PLACEID, placeId, GetRuleTemplatesByCategoryRequest.ATTR_CATEGORY, category));
ClientFuture<ClientEvent> result = client.request(request);
return Futures.transform(result, new Function<ClientEvent, GetRuleTemplatesByCategoryResponse>() {
@Override
public GetRuleTemplatesByCategoryResponse apply(ClientEvent input) {
GetRuleTemplatesByCategoryResponse response = new GetRuleTemplatesByCategoryResponse(input);
IrisClientFactory.getModelCache().addOrUpdate(response.getRuleTemplates());
return response;
}
});
}
15
Source : NettyIrisClient2.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public void submit(ClientRequest clientRequest) {
if (!isAuthenticated()) {
throw new IllegalStateException("Client is not authenticated. Please login() first");
}
ClientMessage message = ClientMessage.builder().isRequest(false).withDestination(clientRequest.getAddress()).withType(clientRequest.getCommand()).withAttributes(clientRequest.getAttributes()).create();
try {
websocketSendMessage(clientRequest, message);
} catch (IllegalStateException ex) {
close();
logger.error("Unable to send message.", ex);
}
}
15
Source : SecuritySettingsController.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void setAlarmSensitivityPartialMode(int alarmSensitivityPartialMode) {
ClientRequest request = new ClientRequest();
request.setCommand(Capability.CMD_SET_ATTRIBUTES);
request.setAttribute(CapabilityInstances.getAttributeName(SecuritySubsystem.ALARMMODE_PARTIAL, SecurityAlarmMode.ATTR_ALARMSENSITIVITYDEVICECOUNT), alarmSensitivityPartialMode);
sendRequest(request);
}
See More Examples