Send all notifications in the queue.

@since 2.0.17
@access public
489364
public function SendNotificationQueue() {
      foreach ($this->_NotificationQueue as $UserID => $Notifications) {
         if (is_array($Notifications)) {
            // Only send out one notification per user.
            $Notification = $Notifications[0];
            
            $Email = $Notification['Email'];
            
            if (is_object($Email)) {
               $this->EventArguments = $Notification;
               $this->FireEvent('BeforeSendNotification');

               try {
                  // Only send if the user is not banned
                  $User = Gdn::UserModel()->GetID($UserID);
                  if (!GetValue('Banned', $User))
                     $Email->Send();
                  
                  $Emailed = self::SENT_OK;
               } catch (phpmailerException $pex) {
                  if ($pex->getCode() == PHPMailer::STOP_CRITICAL)
                     $Emailed = self::SENT_FAIL;
                  else
                     $Emailed = self::SENT_ERROR;
               } catch(Exception $Ex) {
                  $Emailed = self::SENT_FAIL;
               }
               
               try {
                  $this->SQL->Put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $Notification['ActivityID']));
               } catch (Exception $Ex) {
               }
            }
         }
      }

      // Clear out the queue
      unset($this->_NotificationQueue);
      $this->_NotificationQueue = array();
   }
373340
public function send(Notification $notification)
    {
        $message = $this->composeMessage($notification);
        $message->send($this->mailer);
    }
320318
async def send_notification(self, method, args=()):
        ''''''
        message = self.connection.send_notification(Notification(method, args))
        await self._send_message(message)
294137
function() {
                if (chatState && userInfo !== undefined) {
                    /**
                     * Ping messages should be sent ASAP, because
                     * we don't want to wait for send queue, we send them
                     * right through async from here
                     */
                    sendMessage({
                        chatMessageVOType: chatMessageVOTypes.PING,
                        pushMsgType: 5
                    });
                }
                else {
                    sendPingTimeout && clearTimeout(sendPingTimeout);
                }
            }
74722
public function send()
    {
        $args = func_get_args();
        if (count($args) > 1) {
            $message = call_user_func_array('sprintf', $args);
        } else {
            $message = $args[0];
        }
        $this->response->send($message);
    }
876736
def putnotify(self, name, *args):
        """"""
        # self.signals[name][0].send(*args)
        self.queues[name][0].put(*args)
        self.queues[name][1].set()
217206
def send_message m
    @mutex.synchronize do
      @sinks.each do |sink|
        sink << m
        sink.flush if sink.respond_to?(:flush) and level == "debug"
      end
      @buf << m
    end
  end
480097
public function sendAll($msg) : void
    {
        foreach ($this->subscriptionTable->findActive() as $row)
        {
            $this->sendNotification($row, $msg, false);
        }

        if ($flush)
        {
            $this->flush();
        }
    }
1325153
public function flush()
	{
		// Don't do anything if the queue is empty
		if ($this->sendQueue->isEmpty()) {
			$this->logger->info('Flushing the already empty queue of Apns\Gateway with certificate "' . $this->getCertificate()->getDescription() . '"');
			return;
		}

		// Connect to APNS if needed
		if (!is_resource($this->getConnection())) {
			$this->connect();
		}

		$this->logger->info('Flushing ' . $this->getQueueLength() . ' messages from the queue of Apns\Gateway with certificate "' . $this->getCertificate()->getDescription() . '"');

		// Handle all messages in the queue
		while (!$this->sendQueue->isEmpty())
		{
			// Make sure signals to this process are respected and handled
			if (function_exists('pcntl_signal_dispatch')) {
				pcntl_signal_dispatch();
			}

			// Get the next message to send
			$messageEnvelope = $this->sendQueue->dequeue();
			$binaryMessage = $messageEnvelope->getBinaryMessage();

			// Send the message and check if all the bytes are written
			$bytesSend = (int)fwrite($this->getConnection(), $binaryMessage);
			if (strlen($binaryMessage) !== $bytesSend)
			{
				// Something did go wrong while sending this message, retry
				$retryMessageEnvelope = $this->queue( $messageEnvelope->getMessage() );
				$messageEnvelope->setStatus(MessageEnvelope::STATUS_SENDFAILED, $retryMessageEnvelope);
				$this->logger->debug('Failed to send Apns\Message #' . $this->lastMessageId . ' "' . $messageEnvelope->getStatusDescription() . '" to device "' . $messageEnvelope->getMessage()->getDeviceToken() . '" on Apns\Gateway with certificate "' . $this->getCertificate()->getDescription() . '"');

				// Sending failed, need to reconnect the socket
				$this->waitAndCheckForErrorResponse();
				$this->disconnect();
				$this->connect();
			}
			else
			{
				// Mark the message as send without errors
				$messageEnvelope->setStatus(MessageEnvelope::STATUS_NOERRORS);

				// Take a nap to give PHP some time to relax after sending data over the socket
				usleep(self::SEND_INTERVAL);

				// Check for errors
				$this->checkForErrorResponse();
			}
		}

		$this->waitAndCheckForErrorResponse();

		// If there are requeued messages, initiate a new flush
		if ($this->getQueueLength() > 0)
		{
			$this->flush();
		}
		else
		{
			// Clear the message envelope store
			$this->clearMessageEnvelopeStore();
		}
	}
192745
public function send()
    {
        $message = $this->message ?: ($this->task ? ucwords($this->getSystemUser()).' ran the ['.$this->task.'] task.' : ucwords($this->getSystemUser()).' ran a task.');

        $payload = array_merge(['text' => $message, 'channel' => $this->channel], $this->options);

        Request::post("{$this->hook}")->sendsJson()->body($payload)->send();
    }
1067417
public function run()
    {
        if (empty($this->queues)) {
            die('Set queues var containing the list of queues to work.' . PHP_EOL);
        }

        Resque::setBackend($this->redisBackend, $this->database, $this->password);

        if ($this->count > 1) {
            for ($i = 0; $i < $this->count; ++$i) {
                $pid = pcntl_fork();
                if ($pid == -1) {
                    die('Could not fork worker ' . $i . PHP_EOL);
                } elseif (!$pid) {
                    // Child, start the worker
                    $this->_startWorker();
                    break;
                }
            }
        } else {
            if (!empty($this->pidFile)) {
                file_put_contents($this->pidFile, getmypid()) or
                    die('Could not write PID information to ' . $PIDFILE . PHP_EOL);
            }
            // Start a single worker
            $this->_startWorker();
        }
    }
1169486
def send_notification(self, method, args, kwargs):
        """"""
        msg = dumps([1, method, args, kwargs])
        self.send(msg)
403107
public function send()
	{
		if (!$this->_hSocket) {
			throw new ApnsPHP_Push_Exception(
				'Not connected to Push Notification Service'
			);
		}

		if (empty($this->_aMessageQueue)) {
			throw new ApnsPHP_Push_Exception(
				'No notifications queued to be sent'
			);
		}

		$this->_aErrors = array();
		$nRun = 1;
		while (($nMessages = count($this->_aMessageQueue)) > 0) {
			$this->_log("INFO: Sending messages queue, run #{$nRun}: $nMessages message(s) left in queue.");

			$bError = false;
			foreach($this->_aMessageQueue as $k => &$aMessage) {
				if (function_exists('pcntl_signal_dispatch')) {
					pcntl_signal_dispatch();
				}

				$message = $aMessage['MESSAGE'];
				$sCustomIdentifier = (string)$message->getCustomIdentifier();
				$sCustomIdentifier = sprintf('[custom identifier: %s]', empty($sCustomIdentifier) ? 'unset' : $sCustomIdentifier);

				$nErrors = 0;
				if (!empty($aMessage['ERRORS'])) {
					foreach($aMessage['ERRORS'] as $aError) {
						if ($aError['statusCode'] == 0) {
							$this->_log("INFO: Message ID {$k} {$sCustomIdentifier} has no error ({$aError['statusCode']}), removing from queue...");
							$this->_removeMessageFromQueue($k);
							continue 2;
						} else if ($aError['statusCode'] > 1 && $aError['statusCode'] <= 8) {
							$this->_log("WARNING: Message ID {$k} {$sCustomIdentifier} has an unrecoverable error ({$aError['statusCode']}), removing from queue without retrying...");
							$this->_removeMessageFromQueue($k, true);
							continue 2;
						}
					}
					if (($nErrors = count($aMessage['ERRORS'])) >= $this->_nSendRetryTimes) {
						$this->_log(
							"WARNING: Message ID {$k} {$sCustomIdentifier} has {$nErrors} errors, removing from queue..."
						);
						$this->_removeMessageFromQueue($k, true);
						continue;
					}
				}

				$nLen = strlen($aMessage['BINARY_NOTIFICATION']);
				$this->_log("STATUS: Sending message ID {$k} {$sCustomIdentifier} (" . ($nErrors + 1) . "/{$this->_nSendRetryTimes}): {$nLen} bytes.");

				$aErrorMessage = null;
				if ($nLen !== ($nWritten = (int)@fwrite($this->_hSocket, $aMessage['BINARY_NOTIFICATION']))) {
					$aErrorMessage = array(
						'identifier' => $k,
						'statusCode' => self::STATUS_CODE_INTERNAL_ERROR,
						'statusMessage' => sprintf('%s (%d bytes written instead of %d bytes)',
							$this->_aErrorResponseMessages[self::STATUS_CODE_INTERNAL_ERROR], $nWritten, $nLen
						)
					);
				}
				usleep($this->_nWriteInterval);

				$bError = $this->_updateQueue($aErrorMessage);
				if ($bError) {
					break;
				}
			}

			if (!$bError) {
				$read = array($this->_hSocket);
				$null = NULL;
				$nChangedStreams = @stream_select($read, $null, $null, 0, $this->_nSocketSelectTimeout);
				if ($nChangedStreams === false) {
					$this->_log('ERROR: Unable to wait for a stream availability.');
					break;
				} else if ($nChangedStreams > 0) {
					$bError = $this->_updateQueue();
					if (!$bError) {
						$this->_aMessageQueue = array();
					}
				} else {
					$this->_aMessageQueue = array();
				}
			}

			$nRun++;
		}
	}
338667
public function startApproval() {
		$this->Status = 'Started';
		$this->log("Starting {$this->Title}...");
		// Determine if we should use delayed notification
		$recipientGroup = 'all';
		if($this->getConfigSetting('RecipientsDelay')) {
			$this->NotifiedGroup = $recipientGroup = 0;
		}
		// Send to selected group
		$this->sendMessage(self::ALERT_REQUEST, $recipientGroup);
		$this->write();
		return true;
	}
1004115
public function send(): void
	{	
		$sentMessage = $this->baseMethod->send();
		$this->messageId = $sentMessage->getMessageId();
		$this->chatId = $sentMessage->getChat()->getId();

		$this->saveState();
	}
259081
def send_notification(self, method, *args):
        
        message = self._version.create_request(method, args, notification=True)
        self.send_message(message)
13085
public function sendAllHeaders()
    {
        if ($this->status_header !== null) {
            header($this->status_header);
        }

        foreach ($this->headers as $name => $value) {
            header($name . ': ' . $value);
        }
    }