/*
Use the notifyStatus(String event) method in order to trigger an update at the client's page when needed for any new request.
Here will be used for Bye or new Call requests.
349764
protected void notifyStatus(String event){
		BlockingQueue<String> eventsQueue = (LinkedBlockingQueue<String>)getServletContext().getAttribute("eventsQueue");
//		if (eventsQueue == null) eventsQueue = new LinkedBlockingQueue<String>();
//		getServletContext().setAttribute("eventsQueue", eventsQueue);
		
		try {
			eventsQueue.put(event);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}		
	}
1362590
function checkLoadStatus(onload) {
            if (loadCount === resourceCount) {
                // wait 1/2s and execute callback (cheap workaround to ensure everything is loaded)
                if (onload || api.onload) {
                    // make sure we clear the timer
                    clearTimeout(timerId);
                    // trigger the onload callback
                    // we call either the supplied callback (which takes precedence) or the global one
                    var callback = onload || api.onload;
                    setTimeout(function () {
                        callback();
                        me.event.publish(me.event.LOADER_COMPLETE);
                    }, 300);
                }
                else {
                    throw new Error("no load callback defined");
                }
            }
            else {
                timerId = setTimeout(function() {
                    checkLoadStatus(onload);
                }, 100);
            }
        }
1054140
@Override
	protected void notifyHandler(ServerHandlerClass handler) {
	    Object instance = handler.newInstance();
	    assignDataToHandler(handler, instance);
	    ReflectMethodUtil.invokeHandleMethod(handler.getHandleMethod(), 
                instance, context);
	}
1186579
public void updateStatus() {
        Optional<Activity> activity = api.getActivity();
        ObjectNode updateStatus = JsonNodeFactory.instance.objectNode()
                .put("op", GatewayOpcode.STATUS_UPDATE.getCode());
        ObjectNode data = updateStatus.putObject("d")
                .put("status", api.getStatus().getStatusString())
                .put("afk", false)
                .putNull("since");
        ObjectNode activityJson = data.putObject("game");
        activityJson.put("name", activity.isPresent() ? activity.get().getName() : null);
        activityJson.put("type", activity.map(g -> g.getType().getId()).orElse(0));
        activity.ifPresent(g -> g.getStreamingUrl().ifPresent(url -> activityJson.put("url", url)));
        logger.debug("Updating status (content: {})", updateStatus);
        websocket.get().sendText(updateStatus.toString());
    }
1288233
@Override
    public boolean statusUpdate(final String appName, final String id,
                                final InstanceStatus newStatus, String lastDirtyTimestamp,
                                final boolean isReplication) {
        if (super.statusUpdate(appName, id, newStatus, lastDirtyTimestamp, isReplication)) {
            replicateToPeers(Action.StatusUpdate, appName, id, null, newStatus, isReplication);
            return true;
        }
        return false;
    }
696393
private void attributeNotify(ServletRequest request,String name,Object oldValue,Object newValue)
    {
        ServletRequestAttributeEvent event =
            new ServletRequestAttributeEvent(_servletContext,request,name,oldValue==null?newValue:oldValue);
        for (int i=0;i<LazyList.size(_requestAttributeListeners);i++)
        {
            ServletRequestAttributeListener listener = 
                ((ServletRequestAttributeListener)LazyList.get(_requestAttributeListeners,i));
            if (oldValue==null)
                listener.attributeAdded(event);
            else if (newValue==null)
                listener.attributeRemoved(event);
            else
                listener.attributeReplaced(event);
        }
    }
1252845
function _setStatus(status, closeReason) {
        // Don't send a notification when the status didn't actually change
        if (status === exports.status) {
            return;
        }

        exports.status = status;

        var reason = status === STATUS_INACTIVE ? closeReason : null;
        exports.trigger("statusChange", status, reason);
    }
638609
function sendTypingStatus() {
    if (currentDialog.type == 3) {
        QB.chat.sendIsTypingStatus(opponentId);
    } else if (currentDialog && currentDialog.xmpp_room_jid) {
        QB.chat.sendIsTypingStatus(currentDialog.xmpp_room_jid);
    }
}
948110
public void notifyCompletion( URL resource )
    {
        long now = System.currentTimeMillis();
        long time = now - m_start;
        int kBps = (int) ( m_expected / time );
        m_out.println( resource.toExternalForm() + " : " + kBps + " kBps.          " );
    }
286648
public void update(MsNotifyEvent event) {
		logger.info("resource updated : event FQN " + event.getEventID().getFqn());
		if(session != null && link != null && event.getEventID().equals(MsAnnouncement.COMPLETED)) {						
			try {
				SipServletRequest byeRequest = session.createRequest("BYE");				
				byeRequest.send();																	
			} catch (IOException e) {
				logger.error("Unexpected error while sending the BYE request", e);				
			}
			link.release();			
		}
	}
828264
function onHeaders(ev, status, newUrl, oldUrl, statusCode, method, referrer, headers, resourceType) {
    if (resourceType !== 'mainFrame') return;

    let headerArray = [];

    Object.keys(headers).forEach(name => {
      headers[name].forEach(value => {
        headerArray.push({ name, value });
      });
    });

    response = {
      url: newUrl,
      method,
      status: statusCode,
      contentType: headers['content-type'][0],
      headers: headerArray
    };

    notify([ 'header event', status, newUrl, oldUrl, statusCode, method, referrer, headers, resourceType ]);
  }
591955
public void notifyUpdate( URL resource, int expected, int count )
    {
        if( m_first )
        {
            m_expected = expected;
            m_start = System.currentTimeMillis();
            m_first = false;
        }
        int completed = ( count * 100 ) / expected;
        m_out.print( resource.toExternalForm() + " : " + completed + "%    \r" );
    }
1333647
public void onUpdatedStats(ActiveMQQueueJmxStats updatedStats) {
        QueueStatisticsCollection queueStatisticsCollection;

        synchronized ( this.queueStats ) {
            queueStatisticsCollection = this.queueStats.get(updatedStats.getQueueName());

            if ( queueStatisticsCollection == null ) {
                queueStatisticsCollection = new QueueStatisticsCollection(updatedStats.getQueueName());
                this.queueStats.put(updatedStats.getQueueName(), queueStatisticsCollection);
            }
        }

        queueStatisticsCollection.onUpdatedStats(updatedStats);
    }
898428
function onUpdate (update) {
      var value = update[0], ts = update[1], id = update[2]
      insertBatch (id, key, ts, JSON.stringify(value), scuttlebutt)
    }
157404
private void updateServiceCache(String serviceName, ConcurrentHashMap<String, List<URL>> serviceUrls, boolean needNotify) {
        if (serviceUrls != null && !serviceUrls.isEmpty()) {
            List<URL> urls = serviceCache.get(serviceName);
            if (urls == null) {
                if(logger.isDebugEnabled()) {
                    try {
                        logger.debug("serviceUrls = " + Config.getInstance().getMapper().writeValueAsString(serviceUrls));
                    } catch(Exception e) {
                    }
                }
                serviceCache.put(serviceName, serviceUrls.get(serviceName));
            }
            for (Map.Entry<String, List<URL>> entry : serviceUrls.entrySet()) {
                boolean change = true;
                if (urls != null) {
                    List<URL> newUrls = entry.getValue();
                    if (newUrls == null || newUrls.isEmpty() || ConsulUtils.isSame(newUrls, urls)) {
                        change = false;
                    } else {
                        serviceCache.put(serviceName, newUrls);
                    }
                }
                if (change && needNotify) {
                    notifyExecutor.execute(new NotifyService(entry.getKey(), entry.getValue()));
                    logger.info("light service notify-service: " + entry.getKey());
                    StringBuilder sb = new StringBuilder();
                    for (URL url : entry.getValue()) {
                        sb.append(url.getUri()).append(";");
                    }
                    logger.info("consul notify urls:" + sb.toString());
                }
            }
        }
    }
193252
private void nextStatusUpdate() {
		this.nextStatusUpdateNode = NeoUtils.getNextSingleNode(
				this.nextStatusUpdateNode, SocialGraphRelationshipType.UPDATE);

		// load status update time stamp if existing
		if (this.nextStatusUpdateNode != null) {
			this.statusUpdateTimestamp = (long) this.nextStatusUpdateNode
					.getProperty(Properties.StatusUpdate.TIMESTAMP);
		}
	}
402600
public void sendStatusOnly(final HttpResponseStatus status) {
    if (!chan.isConnected()) {
      if(stats != null) {
        stats.markSendFailed();
      }
      done();
      return;
    }

    response.setStatus(status);
    final boolean keepalive = HttpHeaders.isKeepAlive(request);
    if (keepalive) {
      HttpHeaders.setContentLength(response, 0);
    }
    final ChannelFuture future = chan.write(response);
    if (stats != null) {
      future.addListener(new SendSuccess());
    }
    if (!keepalive) {
      future.addListener(ChannelFutureListener.CLOSE);
    }
    done();
  }