/*
Having this separate from messageListener allows us to
avoid using JSON parsing (and its limitations) in the case
of same domain control
977918
function addCallback (t, data) {
  var result = data.result || data.error;
  cbid = data.id;
  if (t.callbacks[cbid]) {
    if (data.result) {
      t.callbacks[cbid](result);
    } else {
      t.callbacks[cbid](result, 'error');
    }
  }
}
547538
function unbindEventListeners(instanceData) {

		var eventDelegates = instanceData.eventDelegates;

		for (var i = 0; i < eventDelegates.length; i++) {
			eventDelegates[i].detachEvents();
		}

		instanceData.eventDelegates = [];
	}
904164
function onStringMessage(data)
    {
        try
        {
            data = (scope.encode) ? JSON.parse(atob(data)) : JSON.parse(data);
        
            switch(data.ev)
            {
                case InternalEvents.REDIRECT:
                {
                    changeServer(data.data);
                    break;
                }
                case InternalEvents.CONNECTED:
                {
                    scope.id = data.data;
                    if(scope.onConnected)
                    {
                        scope.onConnected(scope.id);
                    }
                    break;
                }
                case InternalEvents.JOINED_ROOM:
                {
                    scope.roomUsers   = data.data.users;
                    scope.room        = data.data.room;
                    scope.params      = data.data.params;
                    scope.rtcId       = data.data.rtcId;
                    scope.useRTC      = data.data.useRTC;
                    scope.rtcFallback = data.data.rtcFallback;
                    scope.byteType    = data.data.byteType;

                    if(scope.onJoinedRoom)
                    {
                        scope.onJoinedRoom(scope.room,scope.params);
                    }
                    break;
                }
                case InternalEvents.ROOM_PARAMS:
                {
                    scope.params = data.data;
                    if(scope.onRoomUpdate)
                    {
                        scope.onRoomUpdate(scope.params);
                    }
                    break;
                }
                case InternalEvents.USER_JOINED_ROOM:
                {
                    if(scope.roomUsers)
                    {
                        var hasObject = false;
                        for(var num = 0; num < scope.roomUsers.length; num++)
                        {
                            if(scope.roomUsers[num].id==data.data.id)
                            {
                                hasObject = true;
                                break;
                            }
                        }
                        if(hasObject == false)
                        {
                            scope.roomUsers.push(data.data);
                        }
                    }
                    if(scope.onClientJoinedRoom)
                    {
                        scope.onClientJoinedRoom(data.data.id);
                    }
                    break;
                }
                case InternalEvents.LEFT_ROOM:
                {
                    if(scope.roomUsers)
                    {
                        scope.roomUsers = [];
                    }
                    if(scope.onLeftRoom)
                    {
                        scope.onLeftRoom();
                    }
                    break;
                }
                case InternalEvents.USER_LEFT_ROOM:
                {
                    if(scope.roomUsers)
                    {
                        for(var num = 0; num < scope.roomUsers.length; num++)
                        {
                            if(scope.roomUsers[num].id==data.data)
                            {
                                scope.roomUsers.splice(num,1);
                                break;
                            }
                        }
                    }
                    if(scope.onClientLeftRoom)
                    {
                        scope.onClientLeftRoom(data.data);
                    }
                    break;
                }
                case InternalEvents.SDP_DESCRIPTION:
                {
                    if(scope.onSDPDescription)
                    {
                        scope.onSDPDescription(data.id,data.rtcId,data.data);
                    }
                    break;
                }
                case InternalEvents.ICE_CANDIDATE:
                {
                    if(scope.onIceCandidate)
                    {
                        scope.onIceCandidate(data.id,data.data);
                    }
                    break;
                }
                case InternalEvents.RTC_FALLBACK_LIST:
                {
                    scope.fallbackUsers = data.data;
                    
                    break;
                }
                case InternalEvents.RTC_FALLBACK:
                {
                    if(scope.onRTCFallback)
                    {
                        scope.onRTCFallback(data.from,data.data,false);
                    }
                    break;
                }
                case InternalEvents.PING:
                {
                    scope.send("0",MessageType.PING);
                    break;
                }
                default:
                {
                    if(data.ev)
                    {
                        if(scope.onMessage)
                        {
                            scope.onMessage(data);
                        }
                    }
                    else
                    {
                        if(scope.onRawMessage)
                        {
                            scope.onRawMessage(data);
                        }
                    }
                    break;
                }
            }
        }
        catch(e)
        {
            if(scope.onRawMessage)
            {
                scope.onRawMessage(data);
            }
        }
    }
1135967
public void handleServerNotificationRegistration(RESTRequest request, int clientID, ServerNotificationRegistration serverNotificationRegistration,
                                                     JSONConverter converter) {
        //Get the client area
        ClientNotificationArea clientArea = getInboxIfAvailable(clientID, converter);

        if (serverNotificationRegistration.operation == Operation.RemoveAll) {
            //Unregister with our client area (will also unregister with the MBeanServer)
            clientArea.removeServerNotificationListener(request, serverNotificationRegistration, true, converter, false);

        } else {
            if (serverNotificationRegistration.operation == Operation.Add) {
                //Register with our client area (will also register with the MBeanServer)
                clientArea.addServerNotificationListener(request, serverNotificationRegistration, converter);

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Added server-side notification");
                }

            } else {
                //Unregister with our client area (will also unregister with the MBeanServer)
                clientArea.removeServerNotificationListener(request, serverNotificationRegistration, false, converter, false);
            }
        }
    }
1316898
@SuppressWarnings("unchecked")
    static <T extends SAMLObject> MessageContext<T> toSamlObject(
            AggregatedHttpMessage msg, String name,
            Map<String, SamlIdentityProviderConfig> idpConfigs,
            @Nullable SamlIdentityProviderConfig defaultIdpConfig) {
        requireNonNull(msg, "msg");
        requireNonNull(name, "name");
        requireNonNull(idpConfigs, "idpConfigs");

        final SamlParameters parameters = new SamlParameters(msg);
        final T message = (T) fromDeflatedBase64(parameters.getFirstValue(name));

        final MessageContext<T> messageContext = new MessageContext<>();
        messageContext.setMessage(message);

        final Issuer issuer;
        if (message instanceof RequestAbstractType) {
            issuer = ((RequestAbstractType) message).getIssuer();
        } else if (message instanceof StatusResponseType) {
            issuer = ((StatusResponseType) message).getIssuer();
        } else {
            throw new SamlException("invalid message type: " + message.getClass().getSimpleName());
        }

        // Use the default identity provider config if there's no issuer.
        final SamlIdentityProviderConfig config;
        if (issuer != null) {
            final String idpEntityId = issuer.getValue();
            config = idpConfigs.get(idpEntityId);
            if (config == null) {
                throw new SamlException("a message from unknown identity provider: " + idpEntityId);
            }
        } else {
            if (defaultIdpConfig == null) {
                throw new SamlException("failed to get an Issuer element");
            }
            config = defaultIdpConfig;
        }

        // If this message is sent via HTTP-redirect binding protocol, its signature parameter should
        // be validated.
        validateSignature(config.signingCredential(), parameters, name);

        final String relayState = parameters.getFirstValueOrNull(RELAY_STATE);
        if (relayState != null) {
            final SAMLBindingContext context = messageContext.getSubcontext(SAMLBindingContext.class, true);
            assert context != null;
            context.setRelayState(relayState);
        }

        return messageContext;
    }
1092072
function(message) {
    if (!_.isObject(message)) {
      message = {
        message: message
      };
    }

    try {
      message = JSON.stringify(_.defaultsDeep({}, message, this.config.defaultProps));
    } catch (e) {
      return this.logger.error('Logmatic - error while parsing log message. Not sending', e);
    }

    if (this.isConnected) {
      this.sendMessage(message);
    } else {
      this.messageBuffer.push(message);
    }
  }
943043
function () {
		var message = this.message;
		var name = this.name;
		var url = this.url;
		var result = name;
		if (message) {
			result +=  ': ' + message;
		}
		if (url) {
			result += ' (' + url + ')';
		}
		return result;
	}
1036199
private ObjectJS jsonMessage(String message, StringifierFactory jsonStringifierFactory) {
		ObjectJS bucketsJS = new ObjectJS();
		bucketsJS.setSimpleAttribute("message", message, jsonStringifierFactory.getStringifier(String.class));
		return bucketsJS;
	}
432227
function(){
            var _body,_text;
            try{
                var _body = this.__frame.contentWindow.document.body,
                    _text = (_body.innerText||_body.textContent||'').trim();
                // check result for same domain with upload proxy html
                if (_text.indexOf(_xflag)>=0||
                    _body.innerHTML.indexOf(_xflag)>=0){
                    // use post message path
                    return;
                }
            }catch(ex){
                // ignore if not same domain
                return;
            }
            this.__onLoadRequest(_text);
        }
167638
function Message(instanceList, // @arg InstanceObject - address list. { id: instance, ... }
                 methodName) { // @arg MethodNameString = "inbox" - instance[method]
                               // @desc MessagePassing implementation.
    this._instanceList = instanceList;
    this._methodName   = methodName || "inbox";

//{@dev
    $valid($type(instanceList, "Object"),      Message, "instanceList");
    $valid($type(methodName,   "String|omit"), Message, "methodName");

    for (var id in instanceList) {
        $valid($type(instanceList[id][this._methodName], "Function"), Message, "methodName"); // instance has not method.
    }
//}@dev
}
1368887
@Override
	public void setMessageListener(MessageListener messageListener) throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
		{
    		checkNotClosed();
    		this.messageListener = messageListener;
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
1303753
@Override
    public JsMessage getMessage()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getMessage");

        JsMessage localMsg = getJSMessage(true);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getMessage", localMsg);

        return localMsg;
    }
1352134
public void freeListenersWithSource(Object objSource)
    {
        Object[] rgFilter = m_mapFilters.values().toArray();
        for (int i = 0; i < rgFilter.length; i++)
        {
            BaseMessageFilter filter = (BaseMessageFilter)rgFilter[i];
            if (filter.getMessageSource() == objSource)
            {
                while (filter.getMessageListener(0) != null)
                {
                    JMessageListener listener = filter.getMessageListener(0);
                    filter.removeFilterMessageListener(listener);
                    if (listener instanceof Freeable)
                        ((Freeable)listener).free();
                }                
            }
        }
    }
117447
function (messageEvent) {
		var messageObject = JSON.parse(messageEvent.data || '{}');
		if ((messageObject || {})
			.action && messageObject.action === MESSENGER_CONST.ACTION.CONNECT) {
			appWindow = messageEvent.source;
			appOrigin = messageEvent.origin;
			connectionRequestID = messageObject.id;
			status.initialized = true;
			if (status.enabled) {
				connect();
			}
		}
	}
658708
@JsonProperty
  @Override
  public String getName()
  {
    String name = this.name;
    if (Strings.isNullOrEmpty(name)) {
      name = delegate.getName();
    }
    return name;
  }
360106
public void removeAllListeners(RESTRequest request, ObjectName source_objName, JSONConverter converter) {
        NotificationTargetInformation nti = toNotificationTargetInformation(request, source_objName.getCanonicalName());

        //Get the corresponding List for the given ObjectName
        List<ServerNotification> notifications = serverNotifications.get(nti);

        if (notifications == null) {
            throw ErrorHelper.createRESTHandlerJsonException(new ListenerNotFoundException("There are no listeners registered for ObjectName: " + source_objName.getCanonicalName()),
                                                             converter,
                                                             APIConstants.STATUS_BAD_REQUEST);
        }

        Iterator<ServerNotification> notificationsIter = notifications.iterator();
        while (notificationsIter.hasNext()) {
            ServerNotification currentRegistration = notificationsIter.next();

            if (nti.getRoutingInformation() == null) {
                //Remove from MBeanServer               
                MBeanServerHelper.removeServerNotification(source_objName, //no need to make another ObjectName
                                                           currentRegistration.listener,
                                                           (NotificationFilter) getObject(currentRegistration.filter, null, converter),
                                                           getObject(currentRegistration.handback, null, converter),
                                                           converter);
            } else {
                // Remove the notification listener from the Target-Client Manager through EventAdmin
                MBeanRoutedNotificationHelper helper = MBeanRoutedNotificationHelper.getMBeanRoutedNotificationHelper();
                helper.removeRoutedServerNotificationListener(nti,
                                                              currentRegistration.listener,
                                                              (NotificationFilter) getObject(currentRegistration.filter, null, converter),
                                                              getObject(currentRegistration.handback, null, converter),
                                                              converter);
            }
            //Remove from local list (through iterator)
            notificationsIter.remove();

            //Clean up library
            removeObject(currentRegistration.filter);
            removeObject(currentRegistration.handback);
        }
    }
415981
@Nonnull
    public static <Message extends PMessage<Message, Field>, Field extends PField>
    Message parseDebugString(String string, PMessageDescriptor<Message, Field> descriptor) {
        try {
            ByteArrayInputStream bais = new ByteArrayInputStream(string.getBytes(UTF_8));
            return DEBUG_STRING_SERIALIZER.deserialize(bais, descriptor);
        } catch (IOException e) {
            throw new UncheckedIOException(e.getMessage(), e);
        }
    }