コード例 #1
0
        public void PublishRaw(string frame)
        {
            try
            {
                lock (response)
                {
                    WriteEvent(response, frame);

                    OnPublish?.Invoke(response, frame);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error publishing notification to: " + frame.SafeSubstring(0, 50), ex);
                OnError?.Invoke(this, ex);

                // Mono: If we explicitly close OutputStream after the error socket wont leak (response.Close() doesn't work)
                try
                {
                    // This will throw an exception, but on Mono (Linux/OSX) the socket will leak if we not close the OutputStream
                    response.OutputStream.Close();
                }
                catch (Exception innerEx)
                {
                    Log.Error("OutputStream.Close()", innerEx);
                }

                Unsubscribe();
            }
        }
コード例 #2
0
ファイル: MqttSession.cs プロジェクト: lulzzz/piraeus-2
 internal void Publish(MqttMessage message, bool force = false)
 {
     if (message.QualityOfService != QualityOfServiceLevelType.ExactlyOnce ||
         message.QualityOfService == QualityOfServiceLevelType.ExactlyOnce && force)
     {
         OnPublish?.Invoke(this, new MqttMessageEventArgs(message));
     }
 }
コード例 #3
0
ファイル: MqttSession.cs プロジェクト: skunklab/SkunkLab.Core
 internal void Publish(MqttMessage message, bool force = false)
 {
     //if the message is QoS = 2, the message is held waiting for release.
     if (message.QualityOfService != QualityOfServiceLevelType.ExactlyOnce ||
         (message.QualityOfService == QualityOfServiceLevelType.ExactlyOnce && force))
     {
         OnPublish?.Invoke(this, new MqttMessageEventArgs(message));
     }
 }
コード例 #4
0
        private static void mk_media_publish(IntPtr mk_media_info, IntPtr mk_publish_auth_invoker, IntPtr mk_sock_info)
        {
            var response = new dtos.PublishInvokerDto {
                Message = "不允许推流", EnableHls = false, EnableMp4 = false
            };

            if (OnPublish != null)
            {
                var mediaWapper = new MediaSourceWapper();
                mediaWapper.MediaInfo = new MediaInfo(mk_media_info);
                mediaWapper.SockInfo  = new SockInfo(mk_sock_info);
                var result = OnPublish.Invoke(mediaWapper) ?? response;
                PInvoke.ZLMediaKitMethod.mk_publish_auth_invoker_do(mk_publish_auth_invoker, result.Message, result.EnableHls ? 1 : 0, result.EnableMp4 ? 1 : 0);
                return;
            }
            PInvoke.ZLMediaKitMethod.mk_publish_auth_invoker_do(mk_publish_auth_invoker, response.Message, response.EnableHls ? 1 : 0, response.EnableMp4 ? 1 : 0);
        }
コード例 #5
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="sendBytes"></param>
        /// <param name="routingKey"></param>
        /// <param name="exchangeName"></param>
        /// <param name="isNoConsumerException"></param>
        public Task Publish(byte[] sendBytes, string routingKey = "", string exchangeName = "", bool isNoConsumerException = false)
        {
            using (IModel channel = BindExchange(exchangeName ?? _factory.Config.ExchangeName))
            {
                IBasicProperties properties = null;
                if (_factory.Config.Persistence)
                {
                    properties = channel.CreateBasicProperties();
                    properties.DeliveryMode = 2;
                }
                channel.BasicReturn += async(se, ex) => await Task.Delay(_factory.Config.NoConsumerMessageRetryInterval).ContinueWith((t) => Publish(ex.Body, ex.RoutingKey, ex.Exchange, true));

                channel.BasicPublish(
                    exchange: exchangeName ?? _factory.Config.ExchangeName,
                    routingKey: routingKey,
                    mandatory: true,
                    basicProperties: properties,
                    body: sendBytes);
            }
            OnPublish?.Invoke(this, new OpenTracingMessage(exchangeName, routingKey, Encoding.UTF8.GetString(sendBytes), isNoConsumerException));
            return(Task.CompletedTask);
        }
コード例 #6
0
 public void Publish(Publishable publishable) => OnPublish?.Invoke(publishable);
コード例 #7
0
 public void Publish(object publisher, T eventArgs) => OnPublish?.Invoke(publisher, eventArgs);
コード例 #8
0
 internal static PublishResult OnPublish_Call(PublishInfo publishInfo) => OnPublish?.Invoke(publishInfo);
コード例 #9
0
 public void Publish()
 {
     OnPublish?.Invoke(sceneNameInput.text, sceneDescriptionInput.text);
 }