Beispiel #1
0
        public override void Init(IRequestCommand request, bool requestFailed)
        {
            base.Init(request, requestFailed);

            this.request = request as ContentAccessRequest;

            Assert.IsNotNull(this.request);
        }
Beispiel #2
0
 public virtual void Init(IRequestCommand request, bool requestFailed)
 {
     recipient          = request.Emitter;
     this.requestFailed = requestFailed;
 }
 public void SetUp()
 {
     command = new ListAll();
 }
Beispiel #4
0
 private static void SendBroadcast(IRequestCommand command, IPAddress excludedConnection, int dropChainTailCount)
 {
     if (command == null)
         throw new ArgumentNullException("command");
     try
     {
         m_Connections.Lock();
         RList<Connection> connections = new RList<Connection>();
         foreach (Connection connection in m_Connections.Values)
             if (connection.IsEstablished && !connection.RemoteEndPoint.Address.Equals(excludedConnection))
                 connections.Add(connection);
         dropChainTailCount = Math.Min(dropChainTailCount, connections.Count);
         for (int n = 0; n < dropChainTailCount; n++)
         {
             int index = Randomizer.GenerateNumber(0, connections.Count);
             command.Send(connections[index]);
             connections.RemoveAt(index);
         }
     }
     finally
     {
         m_Connections.Unlock();
     }
 }
Beispiel #5
0
        private static void SendBroadcast(IRequestCommand command, IPAddress excludedConnection)
        {
            if (command == null)
                throw new ArgumentNullException("command");

            foreach (Connection connection in m_Connections.Values)
                if (connection.IsEstablished && !connection.RemoteEndPoint.Address.Equals(excludedConnection))
                    command.Send(connection);
        }
Beispiel #6
0
        private static void SendBroadcast(IRequestCommand command)
        {
            if (command == null)
                throw new ArgumentNullException("command");

            foreach (Connection connection in m_Connections.Values)
                if (connection.IsEstablished)
                    command.Send(connection);
        }
Beispiel #7
0
        private static bool CheckCommand(Connection connection, IRequestCommand command)
        {
            if (command == null)
                throw new ArgumentNullException("command");
            if (connection == null)
                throw new ArgumentNullException("clientConnection");

            Peer peer;
            try
            {
                m_Peers.Lock();
                string idString = ByteArrayToString(command.SenderPeerID);
                if (!m_Peers.TryGetValue(idString, out peer))
                    m_Peers.Add(idString, peer = new Peer());
            }
            finally
            {
                m_Peers.Unlock();
            }
            peer.ReportReceived(connection.RemoteEndPoint.Address);
            string commandIDString = ByteArrayToString(command.CommandID);
            try
            {
                m_LastCommandID.Lock();
                if (m_LastCommandID.ContainsKey(commandIDString))
                {
                    m_LastCommandID[commandIDString] = DateTime.Now;
                    return false;
                }
                m_LastCommandID.Add(commandIDString, DateTime.Now);
            }
            finally
            {
                m_LastCommandID.Unlock();
            }
            peer.ReportReceived();
            return true;
        }
Beispiel #8
0
 public IRequestContext GetRequestContext(IRequestCommand command)
 {
     IRequestContext context;
     try
     {
         context = command.NewContext();
         context[Tokens.CommandBin] = command;
         context[Tokens.FieldTable] = FieldTable;
         // TODO: MessageTable
     }
     catch (Exception e)
     {
         context = new RequestContext();
         context.Fault = e;
         // ISSUE: Log exception(faults) (Log all errors in verbose mode?)
         // ISSUE: Provide an alternate location on fault? -- Declarative exception handing
     }
     return context;
 }