本文整理汇总了PHP中msg_send函数的典型用法代码示例。如果您正苦于以下问题:PHP msg_send函数的具体用法?PHP msg_send怎么用?PHP msg_send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msg_send函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postAction
public function postAction()
{
$line = $_REQUEST['msg'];
$id = $_REQUEST['id'];
$msg_id = msg_get_queue($this->_key, 0600);
die(json_encode(msg_send($msg_id, 1, "{$id}!{$line}", true, true, $msg_err)));
}
示例2: send
/**
* @param $strMessage - message to send to the queue
* @param $intErrorCode - reference to error-code, which is set in case of error
*
* @throw \Exception - if message is not a string
*
* @returns (boolean) true, if message was successfully send to queue
* @returns (boolean) false, if error occured
*
* send the given message to the queue. if the message is to big,
* the sending is blocked, until there is enough space in queue
* to send the message.
*
* if an error occurs, the parameter $intErrorCode will contain
* the error-code.
*
**/
public function send($strMessage, &$intErrorCode = null)
{
if (!is_string($strMessage)) {
throw new \Exception("given parameter must be a string");
}
return msg_send($this->resQueue, 1, $strMessage, false, true, $intErrorCode);
}
示例3: send
public function send($message, $type = 1)
{
if (!@msg_send($this->queue_id, $type, $message, true, false, $err)) {
throw new Exception("From msg_send: {$err}");
}
return true;
}
示例4: shutdown
public function shutdown()
{
$this->queue = msg_get_queue(ftok($this->file, 'R'), 0777);
for ($i = 0; $i < $this->numThreads * 2; $i++) {
msg_send($this->queue, 100 + $i, 'shutdown');
}
}
示例5: log
public static function log($message, $type = '')
{
$contents = trim($message);
if (!$contents) {
return false;
}
if (empty($type)) {
$type = 'common';
}
$queue = self::getInstance();
$msg = json_encode(array('msg' => $contents, 'type' => $type));
msg_send($queue, 1, $msg, false, false, $errorcode);
$unix_time = time();
$Y = date("Y", $unix_time);
$m = date("m", $unix_time);
$d = date("d", $unix_time);
$H = date("H", $unix_time);
$log_dir = self::LC_LOG_PATH . "/" . $type . "/{$Y}/{$m}/{$d}";
if (!is_dir($log_dir)) {
@mkdir($log_dir, 0777, true);
}
$log = $log_dir . "/" . $type . '.' . $H . '.' . "log";
file_put_contents($log, "{$contents}\n", FILE_APPEND);
return true;
}
示例6: push
/**
* {@inheritdoc}
*/
public function push($item, $eta = null)
{
$eta = QueueUtils::normalizeEta($eta);
if (!msg_send($this->getQueue(), $eta, $item, $this->serialize, false, $errorCode)) {
throw new QueueException($this, self::getErrorMessage($errorCode), $errorCode);
}
}
示例7: put
function put($data)
{
$this->init();
if (!@msg_send($this->seg, 1, serialize($data), false, false, $errno)) {
throw new Scalr_System_Ipc_Exception($errno ? self::$msgsnd_errors[$errno] : "Cannot send message", $errno);
}
return true;
}
示例8: send
public function send($message)
{
$result = msg_send($this->queue, 1, $message);
if ($result == False) {
print "end error" . PHP_EOL;
}
return $result;
}
示例9: mqSend
/**
Put a Message Into the Queue
*/
static function mqSend($name, $type, $mess)
{
$mq = msg_get_queue(self::_ftok($name));
$block = true;
$error = null;
if (msg_send($mq, $type, $mess, true, $block, $error)) {
return true;
}
}
示例10: send
public function send($data, $block = false, $serialize = false)
{
$error = 0;
$type = 1;
$r = msg_send($this->msg, $type, $data, $serialize, $block, $error);
if (!$r) {
}
return $r;
}
示例11: send
/**
* Sends message
* @param integer $type
* @param string $msg
* @return void
*/
public function send($type, $msg)
{
$err = 0;
if (!msg_send($this->queue, $type, $msg, true, false, $err)) {
$this->logger->critical("Message of type {$type} not sent: {$err}", (array) $msg);
} else {
$this->logger->debug("Message of type {$type} sent", (array) $msg);
}
}
示例12: putMessage
public function putMessage(&$message)
{
$messageId = $this->storage->saveMessage($message);
// notify queue via ipc
$ipcStat = msg_stat_queue($this->ipcChannel);
if (is_array($ipcStat) && $ipcStat['msg_qnum'] < 5) {
msg_send($this->ipcChannel, 1, '*', false, false, $ipcError);
}
return $messageId;
}
示例13: addMessage
/**
* addMessage: Given a key, store a new message into our queue.
*
* @param $key string - Reference to the message (PK)
* @param $data array - Some data to pass into the message
*/
public static function addMessage($key, $data = array())
{
# What to send
$message = new Message($key, $data);
# Try to send the message
if (msg_send(self::$queue, QUEUE_TYPE_START, $message)) {
print_r(msg_stat_queue(self::$queue));
} else {
echo "Error adding to the queue";
}
}
示例14: send
public static function send($queue, $msg = '')
{
$queue_id = self::get_queue_id($queue);
if (!$queue_id) {
return false;
}
$mqueue = self::get_msg_queue($queue_id);
if (!$mqueue) {
return false;
}
return msg_send($mqueue, 1, $msg, false, false);
}
示例15: sendMessage
public function sendMessage($data)
{
//Generate a random ID for this request
$id = rand();
$message = [$id, $data];
msg_send($this->queue, $this->serverId, $message, true, false);
msg_receive($this->queue, $id, $msgtype, 1000000, $msg, true);
foreach ($msg[0] as $header) {
header($header);
}
return $msg[1];
}