Send a shared object message.

@param name
shared object name
@param currentVersion
the current version
@param persistent
toggle
@param events
shared object events
490991
public void sendSharedObjectMessage(String name, int currentVersion, boolean persistent, Set<ISharedObjectEvent> events) {
        // create a new sync message for every client to avoid concurrent access through multiple threads
        SharedObjectMessage syncMessage = state.getEncoding() == Encoding.AMF3 ? new FlexSharedObjectMessage(null, name, currentVersion, persistent) : new SharedObjectMessage(null, name, currentVersion, persistent);
        syncMessage.addEvents(events);
        try {
            // get the channel for so updates
            Channel channel = getChannel(3);
            if (log.isTraceEnabled()) {
                log.trace("Send to channel: {}", channel);
            }
            channel.write(syncMessage);
        } catch (Exception e) {
            log.warn("Exception sending shared object", e);
        }
    }
594201
public void sendMessage(String message) {
        EventBuilder eventBuilder = new EventBuilder().withMessage(message)
            .withLevel(Event.Level.INFO);
        sendEvent(eventBuilder);
    }
951366
private void sendLifecycleEvent(final LifecycleEvent event) {

		// instantiate and call lifecycle callbacks from configuration file
		final String listeners = Settings.LifecycleListeners.getValue();
		if (listeners != null) {

			final String[] listenerClasses = listeners.split("[\\s ,;]+");
			for (String listenerClass : listenerClasses) {

				if (StringUtils.isNotBlank(listenerClass)) {

					try {
						final HttpServiceLifecycleListener listener = (HttpServiceLifecycleListener) Class.forName(listenerClass).newInstance();
						switch (event) {

							case Started:
								listener.serverStarted();
								break;

							case Stopped:
								listener.serverStopped();
								break;
						}

					} catch (InstantiationException | IllegalAccessException | ClassNotFoundException ex) {

						logger.error("Unable to send lifecycle event to listener " + listenerClass, ex);
					}
				}
			}
		}
	}
683574
public void send(TCQueryRequest event) throws TCAPSendException {

        if (this.previewMode)
            return;

        if (this.state != TRPseudoState.Idle) {
            throw new TCAPSendException("Can not send Begin in this state: " + this.state);
        }

        if (!this.isStructured()) {
            throw new TCAPSendException("Unstructured dialogs do not use Begin");
        }
        try {
            this.dialogLock.lock();
            this.idleTimerActionTaken = true;
            restartIdleTimer();
            TCQueryMessageImpl tcbm = (TCQueryMessageImpl) TcapFactory.createTCQueryMessage();

            // build DP
            tcbm.setDialogTermitationPermission(event.getDialogTermitationPermission());
            tcbm.setOriginatingTransactionId(Utils.encodeTransactionId(this.localTransactionId, this.isSwapTcapIdBytes));

            if (event.getApplicationContextName() != null || event.getConfidentiality() != null
                    || event.getSecurityContext() != null || event.getUserInformation() != null) {
                this.dpSentInBegin = true;
                this.lastACN = event.getApplicationContextName();
                if (event.getUserInformation() != null) {
                    this.lastUI = event.getUserInformation();
                }

                DialogPortion dp = TcapFactory.createDialogPortion();
                dp.setProtocolVersion(TcapFactory.createProtocolVersionFull());
                dp.setApplicationContext(event.getApplicationContextName());
                dp.setUserInformation(event.getUserInformation());
                dp.setSecurityContext(event.getSecurityContext());
                dp.setConfidentiality(event.getConfidentiality());

                tcbm.setDialogPortion(dp);

                if (this.provider.getStack().getStatisticsEnabled()) {
                    if (event.getApplicationContextName() != null) {
                        String acn = ((ApplicationContextImpl) event.getApplicationContextName()).getStringValue();
                        this.provider.getStack().getCounterProviderImpl().updateOutgoingDialogsPerApplicatioContextName(acn);
                    } else {
                        this.provider.getStack().getCounterProviderImpl().updateOutgoingDialogsPerApplicatioContextName("");
                    }
                }
            }

            // now comps
            if (this.scheduledComponentList.size() > 0) {
                Component[] componentsToSend = new Component[this.scheduledComponentList.size()];
                this.prepareComponents(componentsToSend);
                tcbm.setComponent(componentsToSend);
            }

            AsnOutputStream aos = new AsnOutputStream();
            try {
                tcbm.encode(aos);
                this.setState(TRPseudoState.InitialSent);
                if (this.provider.getStack().getStatisticsEnabled()) {
                    this.provider.getStack().getCounterProviderImpl().updateTcQuerySentCount(this);
                }
                this.provider.send(aos.toByteArray(), event.getReturnMessageOnError(), this.remoteAddress, this.localAddress,
                        this.seqControl, this.getNetworkId(), this.localSsn);
                this.scheduledComponentList.clear();
            } catch (Throwable e) {
                if (logger.isEnabledFor(Level.ERROR)) {
                    logger.error("Failed to send message: ", e);
                }
                throw new TCAPSendException("Failed to send TC-Query message: " + e.getMessage(), e);
            }

        } finally {
            this.dialogLock.unlock();
        }
    }
971946
public void transition (Class<?> clazz, String name, Transition trans)
        throws PersistenceException
    {
        if (!isTransitionApplied(clazz, name) && noteTransition(clazz, name)) {
            try {
                trans.run();

            } catch (PersistenceException e) {
                try {
                    clearTransition(clazz, name);
                } catch (PersistenceException pe) {
                    log.warning("Failed to clear failed transition", "class", clazz, "name", name,
                                pe);
                }
                throw e;

            } catch (RuntimeException rte) {
                try {
                    clearTransition(clazz, name);
                } catch (PersistenceException pe) {
                    log.warning("Failed to clear failed transition", "class", clazz, "name", name,
                                pe);
                }
                throw rte;
            }
        }
    }
815551
public void sendMessage(final AVIMMessage message, final AVIMMessageOption messageOption, final AVIMConversationCallback callback) {
    message.setConversationId(conversationId);
    message.setFrom(client.getClientId());
    message.generateUniqueToken();
    message.setTimestamp(System.currentTimeMillis());
    if (!AppConfiguration.getGlobalNetworkingDetector().isConnected()) {
      // judge network status.
      message.setMessageStatus(AVIMMessage.AVIMMessageStatus.AVIMMessageStatusFailed);
      if (callback != null) {
        callback.internalDone(new AVException(AVException.CONNECTION_FAILED, "Connection lost"));
      }
      return;
    }
    final AVIMCommonJsonCallback wrapperCallback = new AVIMCommonJsonCallback() {
      @Override
      public void done(Map<String, Object> result, AVIMException e) {
        if (null == e && null != result) {
          String msgId = (String) result.get(Conversation.callbackMessageId);
          Long msgTimestamp = (Long) result.get(Conversation.callbackMessageTimeStamp);
          message.setMessageId(msgId);
          if (null != msgTimestamp) {
            message.setTimestamp(msgTimestamp);
          }
          message.setMessageStatus(AVIMMessage.AVIMMessageStatus.AVIMMessageStatusSent);
          if ((null == messageOption || !messageOption.isTransient()) && AVIMOptions.getGlobalOptions().isMessageQueryCacheEnabled()) {
            setLastMessage(message);
            storage.insertMessage(message, false);
          } else {
            LOGGER.d("skip inserting into local storage.");
          }
          AVIMConversation.this.lastMessageAt = (null != msgTimestamp)? new Date(msgTimestamp) : new Date();
          storage.updateConversationLastMessageAt(AVIMConversation.this);
        } else {
          message.setMessageStatus(AVIMMessage.AVIMMessageStatus.AVIMMessageStatusFailed);
        }
        if (null != callback) {
          callback.internalDone(AVIMException.wrapperAVException(e));
        }
      }
    };

    message.setMessageStatus(AVIMMessage.AVIMMessageStatus.AVIMMessageStatusSending);
    if (AVIMFileMessage.class.isAssignableFrom(message.getClass())) {
      AVIMFileMessageAccessor.upload((AVIMFileMessage) message, new SaveCallback() {
        public void done(AVException e) {
          if (e != null) {
            message.setMessageStatus(AVIMMessage.AVIMMessageStatus.AVIMMessageStatusFailed);
            if (callback != null) {
              callback.internalDone(e);
            }
          } else {
            InternalConfiguration.getOperationTube().sendMessage(client.getClientId(), getConversationId(), getType(),
                    message, messageOption, wrapperCallback);
          }
        }
      });
    } else {
      InternalConfiguration.getOperationTube().sendMessage(client.getClientId(), getConversationId(), getType(),
              message, messageOption, wrapperCallback);
    }
  }
1364079
@Override
    public void setProperty(String name, Object value) {
        message.put(name, value);
    }
971416
@Override
    public IClientSharedObject getSharedObject(String name, boolean persistent) {
        log.debug("getSharedObject name: {} persistent {}", new Object[] { name, persistent });
        ClientSharedObject result = sharedObjects.get(name);
        if (result != null) {
            if (result.isPersistent() != persistent) {
                throw new RuntimeException("Already connected to a shared object with this name, but with different persistence.");
            }
            return result;
        }
        result = new ClientSharedObject(name, persistent);
        sharedObjects.put(name, result);
        return result;
    }
1324525
private void sendSOCreationFailed(RTMPConnection conn, SharedObjectMessage message) {
        log.debug("sendSOCreationFailed - message: {} conn: {}", message, conn);
        // reset the object so we can re-use it
        message.reset();
        // add the error event
        message.addEvent(new SharedObjectEvent(ISharedObjectEvent.Type.CLIENT_STATUS, "error", SO_CREATION_FAILED));
        if (conn.isChannelUsed(3)) {
            // XXX Paul: I dont like this direct write stuff, need to move to event-based
            conn.getChannel(3).write(message);
        } else {
            log.warn("Channel is not in-use and cannot handle SO event: {}", message, new Exception("SO event handling failure"));
            // XXX Paul: I dont like this direct write stuff, need to move to event-based
            conn.getChannel(3).write(message);
        }
    }
475894
@Override
    public void onBusEvent(Event event) {
        if (event instanceof AppVisibleChanged) {
            AppVisibleChanged visibleChanged = (AppVisibleChanged) event;
            if (visibleChanged.isVisible()) {
                onAppVisible();
            } else {
                onAppHidden();
            }
        } else if (event instanceof PeerChatOpened) {
            onConversationVisible(((PeerChatOpened) event).getPeer());
        } else if (event instanceof PeerChatClosed) {
            onConversationHidden(((PeerChatClosed) event).getPeer());
        }
    }
867039
function (eventName, callback) {

                // do nothing if no section is defined (partial refresh usecase)
                if (!this._currentSection) {
                    return;
                }

                var delegate = ariaUtilsDelegate;

                // Fallback mechanism for event that can not be delegated
                if (!delegate.isDelegated(eventName)) {
                    var delegateId = delegate.add(callback);
                    this._currentSection.delegateIds.push(delegateId);
                    this.write(delegate.getFallbackMarkup(eventName, delegateId, true));
                    return;
                }

                // transform callback description into a new callback that will be use by the function doing dispatch
                callback = new aria.utils.Callback(callback);
                this._currentSection.delegateCallbacks.push(callback);

                if (!this._delegateMap) {
                    this._delegateMap = {};
                }

                this._delegateMap[eventName] = callback;

            }
867557
protected void broadcastTo (
        DObject object, Name from, byte levelOrMode, String bundle, String msg)
    {
        if (from == null) {
            SpeakUtil.sendSystem(object, bundle, msg, levelOrMode /* level */);

        } else {
            SpeakUtil.sendSpeak(object, from, bundle, msg, levelOrMode /* mode */);
        }
    }
697077
public void registerVersion(Version versionToAdd) {
    String versionName = keyHandler.handle(versionToAdd.getName());
    versions.put(versionName, versionToAdd);
    notifyReportableObservers(versionToAdd);
  }
1288000
@Override
    public boolean removeAttribute(String name) {
        boolean result = true;
        // Send confirmation to client
        final SharedObjectEvent event = new SharedObjectEvent(Type.CLIENT_DELETE_DATA, name, null);
        if (ownerMessage.addEvent(event)) {
            if (super.removeAttribute(name)) {
                modified.set(true);
                syncEvents.add(event);
                deleteStats.incrementAndGet();
            } else {
                result = false;
            }
            notifyModified();
        }
        return result;
    }
3645
private void validateClusterVersionChange(Version newClusterVersion) {
        if (!clusterVersion.isUnknown() && clusterVersion.getMajor() != newClusterVersion.getMajor()) {
            throw new IllegalArgumentException("Transition to requested version " + newClusterVersion
                    + " not allowed for current cluster version " + clusterVersion);
        }
    }
476302
private static void shareMethod(String message, String activityInfoName) {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_TEXT, message);
        PackageManager pm = QuickUtils.getContext().getPackageManager();
        List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
        for (final ResolveInfo app : activityList) {
            if ((app.activityInfo.name).contains(activityInfoName)) {
                final ActivityInfo activity = app.activityInfo;
                final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
                shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                shareIntent.setComponent(name);
                QuickUtils.getContext().startActivity(shareIntent);
                break;
            }
        }
    }
1289756
@Override
    public void setHeader(String name, String value) {
        synchronized (portal) {
            super.setHeader(name, value);
        }
    }