/// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public override Message ReceiveDirectCall(Message message)
        {
            try
            {
                //Type type = entity.Message.GetType();
                //object t = Activator.CreateInstance(type);

                XmlSerializer s = new XmlSerializer(message.GetType());

                s.Serialize(_fileStream, message);
            }
            catch (Exception e)
            {
                SystemMonitor.Error("Serialization failure [" + e.Message + "]");
            }

            return null;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="requestMessage"></param>
        /// <returns></returns>
        public virtual bool MessageAllowed(Message message)
        {
            if (!_enabled)
            {
                return true;
            }

            Type requiredType = message.GetType();

            foreach (Type messageType in _allowedNonAddressedMessageTypes)
            {
                if (messageType == requiredType)
                {// Type matched.
                    return true;
                }

                if (_allowChildrenTypes && requiredType.IsSubclassOf(messageType))
                {// Subclasses allowed and this is one.
                    return true;
                }
            }

            return false;
        }
        /// <summary>
        /// This is an entry point for the direct call mechanism. So optimization is on speed and not functionality.
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public override Message ReceiveDirectCall(Message message)
        {
            FastInvokeHelper.FastInvokeHandlerDelegate handler = GetMessageHandler(message);
            if (handler != null)
            {
                return((Message)handler(this, new object[] { message }));
            }
            else
            {// We failed to find a handler for this type or for any of the parent ones.
                TracerHelper.TraceError("Client instance did not handle a request message received, client [" + this.GetType().Name + "], message [" + message.GetType().Name + "].");
                return(null);
            }

            //Message responceMessage = (Message)invokeMethodInfo.Invoke(this, new object[] { message });
            //return responceMessage;
        }
예제 #4
0
        /// <summary>
        /// The direct call allows to circumvent the many steps (incl serialization) of typical message sending
        /// and make a direct call to another Arbiter member; thus making a much faster delivery. This path
        /// has a maximum optimization for speed, so tracing etc. are disabled.
        ///
        /// Also this mechanism only works for TransportClients currently.
        ///
        /// The mechanism does not utilize any new threads, and the execution is performed on the calling thread.
        ///
        /// Direct calls can only be made to participants on the same arbiter, and no addressing is applied
        /// for the messages.
        /// </summary>
        public Message DirectCall(ArbiterClientId senderID, ArbiterClientId receiverID, Message message)
        {
            IArbiterClient receiver = GetClientByID(receiverID, true);

            if (receiver == null || receiver is TransportClient == false)
            {
                SystemMonitor.OperationWarning("Sender [" + senderID.Id.Print() + "] creating conversation message [" + message.GetType().Name + " ] by not present receiver [" + receiverID.Id.Print() + "] or receiver not a TransportClient");
                return(null);
            }

            Message response = receiver.ReceiveDirectCall(message);

            return(response);
        }
예제 #5
0
        /// <summary>
        /// Will start a shoutcast mode conversation, the sender sending to all.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="requestMessage"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public ConversationMultiPoint CreateConversation(ArbiterClientId senderID, Message message, TimeSpan timeout)
        {
            if (message is TransportMessage)
            {
                SystemMonitor.CheckError(((TransportMessage)message).TransportInfo.CurrentTransportInfo != null);
                TracerHelper.Trace("sender[" + senderID.Id.Name + "], message [" + message.GetType().Name + "] [" + ((TransportMessage)message).TransportInfo.TransportInfoCount + "]");
            }
            else
            {
                TracerHelper.Trace("sender[" + senderID.Id.Name + "], message [" + message.GetType().Name + "]");
            }

            if (GetClientByID(senderID, false) == null)
            {
                SystemMonitor.Error("Creating conversation by not present sender/owner.");
                return null;
            }

            ConversationMultiPoint conversation = new ConversationMultiPoint(_executionManager, message, senderID, GatherMessageClients(message, senderID), timeout);

            if (_isDisposed)
            {// Possible to get disposed while operating here.
                return null;
            }

            lock (_timeOutMonitor)
            {
                _timeOutMonitor.AddEntity(conversation);
            }
            return conversation;
        }
예제 #6
0
        /// <summary>
        /// The direct call allows to circumvent the many steps (incl serialization) of typical message sending
        /// and make a direct call to another Arbiter member; thus making a much faster delivery. This path
        /// has a maximum optimization for speed, so tracing etc. are disabled.
        /// 
        /// Also this mechanism only works for TransportClients currently.
        /// 
        /// The mechanism does not utilize any new threads, and the execution is performed on the calling thread.
        /// 
        /// Direct calls can only be made to participants on the same arbiter, and no addressing is applied
        /// for the messages.
        /// </summary>
        public Message DirectCall(ArbiterClientId senderID, ArbiterClientId receiverID, Message message)
        {
            IArbiterClient receiver = GetClientByID(receiverID, true);
            if (receiver == null || receiver is TransportClient == false)
            {
                SystemMonitor.OperationWarning("Sender [" + senderID.Id.Print() + "] creating conversation message [" + message.GetType().Name + " ] by not present receiver [" + receiverID.Id.Print() + "] or receiver not a TransportClient");
                return null;
            }

            Message response = receiver.ReceiveDirectCall(message);
            return response;
        }