Exemplo n.º 1
0
        protected internal virtual void OnMessageReceived(Stream messageBody)
        {
            ClusterMessage message = m_formatter.Deserialize(messageBody);

            SnTrace.Messaging.Write("Received a '{0}' message.", message.GetType().FullName);

            lock (MessageListSwitchSync)
            {
                _incomingMessages.Add(message);

                //TODO: trace incoming and total message count
                // var totalMessages = _incomingMessages.Count + _messagesCount;
            }
        }
Exemplo n.º 2
0
 /* ============================================================================== Send */
 public virtual void Send(ClusterMessage message)
 {
     try
     {
         message.SenderInfo = m_clusterMemberInfo;
         message.SenderInfo.ClusterMemberID = this.ReceiverName;
         Stream messageStream = m_formatter.Serialize(message);
         SnTrace.Messaging.Write("Sending a '{0}' message", message.GetType().FullName);
         InternalSend(messageStream, message is DebugMessage);
     }
     catch (Exception e) // logged
     {
         SnLog.WriteException(e);
         SnTrace.Messaging.WriteError("Sending a '{0}' message. Exception: {1}", message.GetType().FullName, e);
         OnSendException(message, e);
     }
 }
Exemplo n.º 3
0
        /* ============================================================================== Send */
        public virtual async Task SendAsync(ClusterMessage message, CancellationToken cancellationToken)
        {
            try
            {
                message.SenderInfo = m_clusterMemberInfo;
                message.SenderInfo.ClusterMemberID = ReceiverName;

                Stream messageStream = m_formatter.Serialize(message);
                SnTrace.Messaging.Write("Sending a '{0}' message", message.GetType().FullName);

                await InternalSendAsync(messageStream, message is DebugMessage, cancellationToken).ConfigureAwait(false);
            }
            catch (Exception e) // logged
            {
                SnLog.WriteException(e);
                SnTrace.Messaging.WriteError("Sending a '{0}' message. Exception: {1}", message.GetType().FullName, e);
                OnSendException(message, e);
            }
        }