public void SendResponse(object sender, IResponse response) { if (sender == null) throw new ArgumentNullException(nameof(sender)); if (response == null) throw new ArgumentNullException(nameof(response)); if (State == PortState.Close) throw new StateException($"{this} closed"); var senderMac = sender as string; if (senderMac == null || senderMac != _registeredTerminalMAC) return; if (!IsPortBinded) { var r = new DropedResponse(response.Request, DropedResponse.PortUnbind); OnProcessResponseEvent(r); return; } if (!IsBindedPortNotClosed) { var r = new DropedResponse(response.Request, DropedResponse.TargetPortUnplagged); OnProcessResponseEvent(r); return; } OnSendResponseEvent(SendResponsePreparation(response)); }
public virtual void ProcessResponse(object sender, IResponse response) { if (sender == null) throw new ArgumentNullException(nameof(sender)); if (response == null) throw new ArgumentNullException(nameof(response)); if (State == PortState.Close) throw new StateException($"{this} closed"); if (State == PortState.Open) return; var senderMac = sender as string; if (senderMac == null || senderMac != _bindedPortMAC) return; if (!IsTerminalRegistered) { var r = new DropedResponse(response.Request, DropedResponse.TerminalNotRegistered); OnSendResponseEvent(r); return; } if (!IsRegisteredTerminalPluged) { var r = new DropedResponse(response.Request, DropedResponse.TerminalUnplagged); OnSendResponseEvent(r); return; } OnProcessResponseEvent(ProcessResponsePreparation(response)); }
private void OnDropedEvent(DropedResponse e) { DropedEvent?.Invoke(this, e); }
private void TerminalOnDropedEvent(object sender, DropedResponse dropedResponse) { CallInfo call = RemoveActiveConnectionByActor(dropedResponse.Request.Sender); if (call != null) { OnConnectionFailedEvent(call); UnbindPortsByCall(call); return; } call = RemoveActiveCallByActor(dropedResponse.Request.Sender); if (call != null) { Random r = new Random(); call.Duration = TimeSpan.FromSeconds(r.Next(0, 600)); OnCallEndEvent(call); UnbindPortsByCall(call); } }
public void SendResponse(IResponse response) { if (response == null) throw new ArgumentNullException(nameof(response)); if (State == TerminalState.Unplagged) throw new StateException($"{this} unplagged"); if (State == TerminalState.Offline) return; if (!IsPortRegistered) { var r = new DropedResponse(response.Request, DropedResponse.PortNotRegistered); ProcessResponse(MACAddress, r); return; } if (!IsRegisteredPortNotClosed) { var r = new DropedResponse(response.Request, DropedResponse.PortClose); ProcessResponse(MACAddress, r); return; } OnSendResponseEvent(response); }