public override void Init(IRequestCommand request, bool requestFailed) { base.Init(request, requestFailed); this.request = request as ContentAccessRequest; Assert.IsNotNull(this.request); }
public virtual void Init(IRequestCommand request, bool requestFailed) { recipient = request.Emitter; this.requestFailed = requestFailed; }
public void SetUp() { command = new ListAll(); }
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(); } }
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); }
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); }
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; }
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; }