Sends a message to the webhook channel when server stops.
967711
async def server_stop(app, loop):
    """"""
    em = Embed(color=0xe67e22)
    em.set_footer('Host: {}'.format(socket.gethostname()))
    em.description = '[INFO] Server Stopped'

    await app.webhook.send(embed=em)
    await app.session.close()
74746
def finish!
      if hixie_75? or hixie_76?
        send_data "\xff\x00"
      else
        send_frame OPCODE_CLOSE
      end

      EM.next_tick { callback(:on_finish, self) rescue error! "Error in finish callback" }
      EM.next_tick { close_connection_after_writing }

      @state = :finished
    rescue
      error! "Error finishing WebSocket connection"
    end
1019443
function onMessage(message) {
    if (done) return
    if (message.type != "utf8") return sendConnectFailed(wsConn)

    try {
      message = JSON.parse(message.utf8Data)
    }
    catch(err) {
      return sendConnectFailed(wsConn)
    }

    var id  = message.id

    if (message.type != "request") return sendConnectFailed(wsConn)
    if (message.name != "connect") return sendConnectFailed(wsConn)
    if (message.to   != "server") return sendConnectFailed(wsConn)

    var body = message.body || {}

    if (!body.key) return sendConnectFailed(wsConn)

    var session = sessions.getSession(body.key)
    var channel = channels.createChannel(session, wsConn)

    message = {
      type: "response",
      name: "connect",
      from: "server",
      id:   message.id,
      body: null
    }

    wsConn.sendUTF(JSON.stringify(message))
    cleanUp()
  }
773053
def notify(self, message):
        
        if self.complete:
            return HerokuLocalWrapper.MONITOR_STOP
        return super(DebugDeployment, self).notify(message)
642428
def finish(self, message: Optional[Message_T] = None, **kwargs) -> None:
        """"""
        if message:
            asyncio.ensure_future(self.send(message, **kwargs))
        raise _FinishException
919222
def send_msg_to_webhook(self, json_payload, log_msg):
        
        if SILENCE_OVERRIDE:  # pragma: no cover
            return

        payload = {
            'text': log_msg,
            'attachments':[json_payload]
        }
        header = {
            'Content-Type':'application/json'
        }

        try:
            request = requests.post(
                self.webhook_url,
                headers=header,
                json=payload
            )
            request.raise_for_status()
        except Exception as error_msg:  #pragma: no cover
            warning_msg = (
                'EXCEPTION: UNABLE TO COMMIT LOG MESSAGE' +
                '\n\texception={0}'.format(repr(error_msg)) +
                '\n\tmessage={0}'.format(log_msg)
            )
            warnings.warn(
                warning_msg,
                exceptions.WebhookFailedEmitWarning
            )
1119929
private void send( String message ) {

		if( ! this.enabled.get()) {
			this.logger.finest( "Notifications were disabled by the DM." );

		} else if( message == null ) {
			this.logger.finest( "No message to send to web socket clients." );

		} else synchronized( SESSIONS ) {
			for( Session session : SESSIONS ) {
				try {
					this.logger.finest( "Sending a message to a web socket client..." );
					session.getRemote().sendString( message );

				} catch( IOException e ) {
					StringBuilder sb = new StringBuilder( "A notification could not be propagated for session " );
					sb.append( session.getRemoteAddress());
					sb.append( "." );
					if( ! Utils.isEmptyOrWhitespaces( e.getMessage()))
						sb.append( " " + e.getMessage());

					this.logger.severe( sb.toString());
					Utils.logException( this.logger, e );
				}
			}
		}
	}
494931
def on_close(self):
        '''
        
        '''

        if self.id in self.funcserver.websocks:
            self.funcserver.websocks[self.id] = None
            ioloop = tornado.ioloop.IOLoop.instance()
            ioloop.add_callback(lambda: self.funcserver.websocks.pop(self.id, None))

        psession = self.funcserver.pysessions.get(self.pysession_id, None)
        if psession:
            psession['socks'].remove(self.id)
            if not psession['socks']:
                del self.funcserver.pysessions[self.pysession_id]
703506
def invoke_webhook_handlers(self):
		

		webhooks.call_handlers(event=self)

		signal = WEBHOOK_SIGNALS.get(self.type)
		if signal:
			return signal.send(sender=Event, event=self)
597253
function notifyWebSocket(message) {
	if (!webSocketServer || !message)
		return;
	
	// Send the message to all connection in the WebSocket server.
	for (var value in webSocketServer.conn) {
		var connection = webSocketServer.conn[value];
		if (connection)
			connection.send(message)
	}
}
1279518
function sendMessageOnce( oWs, sCommand, jsonMessage )
{
	//	...
	sendMessage( oWs, sCommand, jsonMessage );

	//	...
	let nCheckInterval = setInterval( () =>
	{
		if ( 0 === oWs.bufferedAmount )
		{
			//	Im' not busy anymore - set a flag or something like that
			clearInterval( nCheckInterval );
			nCheckInterval = null;

			//	close socket
			oWs.close( 1000, 'done' );
		}
	}, 50 );
}
895934
function stop(callback) {
    if (httpServer) {
        DEBUG && debug('stop http server');
        try {
            httpServer.close();
        } catch (e) {
        }
        httpServer = null;
    } else {
        DEBUG && debug('***ignore*** http server is not running!');
    }
    callback && callback(false);
}
1102593
public void sendClose() throws IOException {
        closeReason = "";
        closeCode = CloseMessage.NORMAL_CLOSURE;
        StreamSinkFrameChannel closeChannel = send(WebSocketFrameType.CLOSE);
        closeChannel.shutdownWrites();
        if (!closeChannel.flush()) {
            closeChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(
                    null, new ChannelExceptionHandler<StreamSinkChannel>() {
                @Override
                public void handleException(final StreamSinkChannel channel, final IOException exception) {
                    IoUtils.safeClose(WebSocketChannel.this);
                }
            }
            ));
            closeChannel.resumeWrites();
        }
    }
226576
def on_message(self, message):
        
        log.debug('Got websocket message %s', message)
        if message == 'websocket client ready':
            if self.connected:
                # TBD: Add ability to run commands in this branch
                log.debug('Websocket already connected, returning')
                return

            self.connected = True

            while True:
                try:
                    event = yield self.application.event_listener.get_event(self)
                    self.write_message(
                        salt.utils.json.dumps(event, _json_module=_json))
                except Exception as err:
                    log.info('Error! Ending server side websocket connection. Reason = %s', err)
                    break

            self.close()
        else:
            # TBD: Add logic to run salt commands here
            pass
481619
function(msg) {
        if (onSendLogging)
          asyncLogger("Send", msg);

        switch (protocol) {
          case 'websocket':
            if (socketState === socketStateType.OPEN) {
              socket.emit(msg);
            } else {
              pushSendDataQueue.push(msg);
            }
            break;

          case 'queue':
            if (socketState === socketStateType.OPEN) {
              activemq.sendMessage({
                destination: params.queueSend,
                message: msg
              });
            } else {
              pushSendDataQueue.push(msg);
            }
            break;
        }
      }
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();
  }
380169
function notifySlack ({ channel, text, webhook }) {
  return fetch(webhook, {
    body: JSON.stringify({
      channel,
      text
    }),
    headers: {
      'Content-Type': 'application/json'
    },
    method: 'POST'
  })
    .then(response => response.text())
    .catch(err => {
      logToErrorConsole('Error posting to Slack webhook')
      logToErrorConsole(err)
      return err
    })
}