/// <summary> /// Constructor. /// </summary> /// <param name="comminicatorId">Unique identifier for this communicator.</param> protected CommunicatorBase(long comminicatorId) { ComminicatorId = comminicatorId; CommunicationWay = CommunicationWays.Send; _state = CommunicationStates.Closed; _sendLock = new object(); }
/// <summary> /// Creates a new TCPChannel object. /// </summary> /// <param name="ipAddress">IP address of NGRID server</param> /// <param name="port">TCP port of NGRID server</param> public TCPChannel(string ipAddress, int port) { _ipAddress = ipAddress; _port = port; _state = CommunicationStates.Closed; CommunicationWay = CommunicationWays.SendAndReceive; _wireProtocol = new NGRIDDefaultWireProtocol(); _sendLock = new object(); }
/// <summary> /// Changes the state of the client and raises StateChanged event. /// </summary> /// <param name="newState">New state</param> private void ChangeState(CommunicationStates newState) { var oldState = _state; _state = newState; if (StateChanged != null) { StateChanged(this, new CommunicationStateChangedEventArgs { OldState = oldState }); } }
/// <summary> /// Changes the state of the communicator and raises event /// </summary> /// <param name="newState">New state</param> protected void OnChangeState(CommunicationStates newState) { var oldState = _state; _state = newState; if (StateChanged != null) { StateChanged(this, new CommunicatorStateChangedEventArgs { Communicator = this, OldState = oldState }); } }
/// <summary> /// ֹͣ /// </summary> public void Abort() { try { _communicationState = CommunicationStates.Closing; InnerAbort(); _communicationState = CommunicationStates.Closed; } catch (System.Exception ex) { _communicationState = CommunicationStates.Faulte; _tracing.Error(ex, null); FaultedHandler(null); throw; } }
/// <summary> /// ´ò¿ª /// </summary> public void Open() { try { _communicationState = CommunicationStates.Opening; OpeningHandler(null); InnerOpen(); _communicationState = CommunicationStates.Opened; OpenedHandler(null); } catch (System.Exception ex) { _communicationState = CommunicationStates.Faulte; _tracing.Error(ex, null); FaultedHandler(null); throw; } }
/// <summary> /// Creates a new TCPChannel object. /// </summary> /// <param name="ipAddress">IP address of MDS server</param> /// <param name="port">TCP port of MDS server</param> public TCPChannel(string ipAddress, int port) { _ipAddress = ipAddress; _port = port; _state = CommunicationStates.Closed; CommunicationWay = CommunicationWays.SendAndReceive; _wireProtocol = new MDSDefaultWireProtocol(); _sendLock = new object(); }
/// <summary> /// Changes the state of the communicator and raises event /// </summary> /// <param name="newState">New state</param> protected void OnChangeState(CommunicationStates newState) { var oldState = _state; _state = newState; if (StateChanged != null) { StateChanged(this, new CommunicatorStateChangedEventArgs {Communicator = this, OldState = oldState}); } }