public DataTerminalSession(TcpClient MyTCPClient, NetworkStream MyTCPStream, CloseConnectionDelegate MyCloseConnectionMethod, UpdateCompleteDelegate InformAboutUpdateComplete, ReceiveMessage receiveMessage, Guid sessionId) { TCPClient = MyTCPClient; TCPStream = MyTCPStream; DeleteConnection = MyCloseConnectionMethod; this.receiveMessage = receiveMessage; this.SessionId = sessionId; //Server1CAgent = new HandlingVia1CServer(@"Srvr=""localhost""; Ref=""newwms"";"); //Server1CAgent = new HandlingVia1CServer(@"Srvr=""localhost""; Ref=""iboya81""; Usr=""Оборский Д.В.""; Pwd=""123456"""); //Server1CAgent = new HandlingVia1CServer(@"File=""C:\Documents and Settings\Reshifa\My Documents\InfoBase9""; Usr=""Denis.V.O""; Pwd=""123"""); this.InformAboutUpdateComplete = InformAboutUpdateComplete; }
public void CloseConnection(bool useCloseConnection) { // Setup Mock <CloseConnectionDelegate> mockCloseConnection = new Mock <CloseConnectionDelegate>(); CloseConnectionDelegate connectionClose = null; _mockConnection.SetupSet(c => c.OnCloseConnection = It.IsAny <CloseConnectionDelegate>()).Callback <CloseConnectionDelegate>(c => connectionClose = c); Remote remote = new Remote(_mockConnection.Object); if (useCloseConnection) { remote.CloseConnection += mockCloseConnection.Object; } // Act connectionClose(); // Verify mockCloseConnection.Verify(c => c(), Times.Exactly(useCloseConnection ? 1 : 0)); }
/// <summary> /// /// </summary> public void CloseConnectionThreadSafe() { if (this.InvokeRequired) { //Not in the proper thread, invoke ourselves CloseConnectionDelegate d = new CloseConnectionDelegate(CloseConnectionThreadSafe); this.Invoke(d, new object[] { }); } else { //We are in the proper thread if (IsClientReady()) { string sessionId = iClient.SessionId; Trace.TraceInformation("Closing client: " + sessionId); iClient.Close(); Trace.TraceInformation("Closed client: " + sessionId); } iClient = null; } }
public Int32 CloseConnection( Int32 ConnectionHandle, Hashtable InParameters, ref Hashtable OutParameters ) { Int32 ReturnCode = Constants.ERROR_CONNECTION_DISCONNECTED; if( RemoteInterfaceAlive ) { try { CloseConnectionDelegate DCloseConnection = new CloseConnectionDelegate( RemoteInterface.CloseConnection ); IAsyncResult Result = DCloseConnection.BeginInvoke( ConnectionHandle, InParameters, ref OutParameters, null, null ); WaitHandle.WaitAny( new WaitHandle[2] { Result.AsyncWaitHandle, RemoteInterfaceDropped } ); if( Result.IsCompleted ) { ReturnCode = DCloseConnection.EndInvoke( ref OutParameters, Result ); } } catch( Exception ) { } // Always signal this as when the connection is dropped SignalConnectionDropped(); } return ReturnCode; }
public void Setup() { _mockRemote = new Mock <IRemote>(); _mockAuditor = new Mock <MachineAuditorDelegate>(); _receiveCoreAction = null; _mockRemote.SetupSet(r => r.ReceivePing = It.IsAny <ReceivePingDelegate>()).Callback <ReceivePingDelegate>(callback => _receivePing = callback); _mockRemote.SetupSet(r => r.ReceiveName = It.IsAny <ReceiveNameDelegate>()).Callback <ReceiveNameDelegate>(callback => _receiveName = callback); _mockRemote.SetupSet(r => r.ReceiveRequestAvailableMachines = It.IsAny <ReceiveRequestAvailableMachinesDelegate>()).Callback <ReceiveRequestAvailableMachinesDelegate>(callback => _receiveRequestAvailableMachines = callback); _mockRemote.SetupSet(r => r.ReceiveSelectMachine = It.IsAny <ReceiveSelectMachineDelegate>()).Callback <ReceiveSelectMachineDelegate>(callback => _receiveSelectMachine = callback); _mockRemote.SetupSet(r => r.ReceiveCoreAction = It.IsAny <ReceiveCoreActionDelegate>()).Callback <ReceiveCoreActionDelegate>(callback => _receiveCoreAction = callback); _mockRemote.SetupSet(r => r.CloseConnection = It.IsAny <CloseConnectionDelegate>()).Callback <CloseConnectionDelegate>(callback => _closeConnection = callback); }