/** * Sends a disconnect command message to the client bus * * @param bus * - the bus responsible for sending messages for the server * @param message * - the message that has encountered the error */ public static void disconnectRemoteBus(MessageBus bus, Message message) { MessageBuilder.createConversation(message) .toSubject("ClientBus") .command(BusCommand.Disconnect) .noErrorHandling().sendNowWith(bus); }
@Override public void onUnsubscribe(final SubscriptionEvent event) { if (event.isLocalOnly() || event.isRemote() || event.getSubject().startsWith("local:")) return; if (messageQueues.isEmpty()) return; MessageBuilder.createMessage() .toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.RemoteUnsubscribe) .with(MessageParts.Subject, event.getSubject()) .noErrorHandling().sendGlobalWith(ServerMessageBusImpl.this); } }
@Override public void onSubscribe(final SubscriptionEvent event) { if (event.isLocalOnly() || event.isRemote() || event.getSubject().startsWith("local:")) return; MessageBuilder.createMessage() .toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.RemoteSubscribe) .with(MessageParts.Subject, event.getSubject()) .noErrorHandling().sendGlobalWith(ServerMessageBusImpl.this); } }
.command(BusCommand.WebsocketChannelOpen) .with(MessageParts.WebSocketToken, reconnectionToken) .done().sendNowWith(ServerMessageBusImpl.this, false);
private void notifyPendingClients() { MessageBuilder.createMessage() .toSubject(subject) .command(ShoutboxCmd.SUBMIT_OFFER) .with(ShoutboxCmdParts.SUBJECT, subject) .with(ShoutboxCmdParts.PROVIDER, provider) .noErrorHandling().sendNowWith(bus); matchedClients.addAll(pendingClients); pendingClients.clear(); }
private static void unsubscribe(final String eventType, final AbstractCDIEventCallback<?> callback) { if (eventObservers.containsKey(eventType)) { eventObservers.get(eventType).remove(callback); if (!localOnlyObserverTypes.contains(eventType)) { boolean shouldUnsubscribe = true; for (final AbstractCDIEventCallback<?> cb : eventObservers.get(eventType)) { if (cb.getQualifiers().equals(callback.getQualifiers())) { // found another matching observer -> do not unsubscribe shouldUnsubscribe = false; break; } } if (isRemoteCommunicationEnabled() && shouldUnsubscribe) { MessageBuilder.createMessage() .toSubject(CDI.SERVER_DISPATCHER_SUBJECT) .command(CDICommands.RemoteUnsubscribe) .with(CDIProtocol.BeanType, eventType) .with(CDIProtocol.Qualifiers, callback.getQualifiers()) .noErrorHandling().sendNowWith(ErraiBus.get()); } if (eventObservers.get(eventType).isEmpty()) { eventObservers.remove(eventType); } } } }
/** * Sends a disconnect command message to the client bus * * @param bus * - the bus responsible for sending messages for the server * @param message * - the message that has encountered the error */ public static void disconnectRemoteBus(MessageBus bus, Message message) { MessageBuilder.createConversation(message) .toSubject("ClientBus") .command(BusCommand.Disconnect) .noErrorHandling().sendNowWith(bus); }
public void onClick(ClickEvent clickEvent) { MessageBuilder.createMessage() .toSubject("AuthenticationService") .command(SecurityCommands.EndSession) .noErrorHandling().sendNowWith(ErraiBus.get()); } }
@Override public void onUnsubscribe(final SubscriptionEvent event) { if (event.isLocalOnly() || event.isRemote() || event.getSubject().startsWith("local:")) return; if (messageQueues.isEmpty()) return; MessageBuilder.createMessage() .toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.RemoteUnsubscribe) .with(MessageParts.Subject, event.getSubject()) .noErrorHandling().sendGlobalWith(ServerMessageBusImpl.this); } }
/** * USED can transition either to OPEN (clients left) * or PENDING (provider left). * * @param nextState */ private void leaveUsed(State nextState) { if (State.OPEN == nextState) { // ignore for now, we don't need to notify providers } else if (State.PENDING == nextState) { createMessage() .toSubject(subject) .command(ShoutboxCmd.RETRACT_OFFER) .with(ShoutboxCmdParts.SUBJECT, subject) .with(ShoutboxCmdParts.PROVIDER, provider) .noErrorHandling() .sendNowWith(bus); pendingClients.addAll(matchedClients); matchedClients.clear(); } else { throw new IllegalTransition(nextState); } }
public void retractOffer(String provider, String subjectMatter) { createMessage() .toSubject(ShoutboxModule.INBOX) .command(ShoutboxCmd.RETIRE_OFFER) .with(ShoutboxCmdParts.SUBJECT, subjectMatter) .with(ShoutboxCmdParts.PROVIDER, provider) .noErrorHandling().sendNowWith(bus); }
public void retireOffer(String client, String subjectMatter) { MessageBuilder.createMessage() .toSubject(ShoutboxModule.INBOX) .command(ShoutboxCmd.RETIRE_OFFER) .with(ShoutboxCmdParts.SUBJECT, subjectMatter) .with(ShoutboxCmdParts.CLIENT, client) .noErrorHandling() .sendNowWith(bus); } }
public void submitOffer(String provider, String subjectMatter) { createMessage() .toSubject(ShoutboxModule.INBOX) .command(ShoutboxCmd.SUBMIT_OFFER) .with(ShoutboxCmdParts.SUBJECT, subjectMatter) .with(ShoutboxCmdParts.PROVIDER, provider) .noErrorHandling().sendNowWith(bus); }
public void onClose(CloseEvent closeEvent) { createMessage() .toSubject("org.jboss.errai.WorkspaceLayout") .command(LayoutCommands.CloseTab) .with(LayoutParts.InstanceID, instanceId) .noErrorHandling().sendNowWith(ErraiBus.get()); }
public void closeTab(String instanceId) { MessageBuilder.createMessage() .toSubject(getInstanceSubject(instanceId)) .command(LayoutCommands.CloseTab) .with(LayoutParts.InstanceID, instanceId) .noErrorHandling().sendNowWith(ErraiBus.get()); }
@Override public void onSubscribe(final SubscriptionEvent event) { if (event.isLocalOnly() || event.isRemote() || event.getSubject().startsWith("local:")) return; MessageBuilder.createMessage() .toSubject(BuiltInServices.ClientBus.name()) .command(BusCommand.RemoteSubscribe) .with(MessageParts.Subject, event.getSubject()) .noErrorHandling().sendGlobalWith(ServerMessageBusImpl.this); } }
public void onClick(ClickEvent clickEvent) { Log.debug("ToolID: "+ tool.getId()); MessageBuilder.createMessage() .toSubject(Workspace.SUBJECT) .command(LayoutCommands.ActivateTool) .with(LayoutParts.TOOL, tool.getId()) .with(LayoutParts.TOOLSET, toolSetId) .noErrorHandling() .sendNowWith(ErraiBus.get()); } }
public static Subscription subscribe(final String eventType, final AbstractCDIEventCallback<?> callback) { if (isRemoteCommunicationEnabled() && ErraiBus.get() instanceof ClientMessageBusImpl && ((ClientMessageBusImpl) ErraiBus.get()).getState().equals(BusState.CONNECTED)) { MessageBuilder.createMessage() .toSubject(CDI.SERVER_DISPATCHER_SUBJECT) .command(CDICommands.RemoteSubscribe) .with(CDIProtocol.BeanType, eventType) .with(CDIProtocol.Qualifiers, callback.getQualifiers()) .noErrorHandling().sendNowWith(ErraiBus.get()); } return subscribeLocal(eventType, callback, false); }
public static Subscription subscribe(final String eventType, final AbstractCDIEventCallback<?> callback) { if (isRemoteCommunicationEnabled() && ErraiBus.get() instanceof ClientMessageBusImpl && ((ClientMessageBusImpl) ErraiBus.get()).getState().equals(BusState.CONNECTED)) { MessageBuilder.createMessage() .toSubject(CDI.SERVER_DISPATCHER_SUBJECT) .command(CDICommands.RemoteSubscribe) .with(CDIProtocol.BeanType, eventType) .with(CDIProtocol.Qualifiers, callback.getQualifiers()) .noErrorHandling().sendNowWith(ErraiBus.get()); } return subscribeLocal(eventType, callback, false); }
private void notifyWorkspace() { MessageBuilder.createMessage() .toSubject(Workspace.SUBJECT) .command(LayoutCommands.Initialize) .noErrorHandling().sendNowWith(ErraiBus.get()); AuthenticationContext authenticationContext = Registry.get(SecurityService.class).getAuthenticationContext(); String userName = authenticationContext != null ? authenticationContext.getName() : "NoAuthentication"; MessageBuilder.createMessage() .toSubject("appContext.login") .with("username", userName) .noErrorHandling() .sendNowWith(ErraiBus.get()); }