本文整理汇总了C#中Session.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Disconnect方法的具体用法?C# Session.Disconnect怎么用?C# Session.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session.Disconnect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Destroy
internal void Destroy(Session session)
{
lock (_syncLock)
{
session.Disconnect(true);
_sessions.Remove(session);
}
}
示例2: Connect
public static bool Connect(int serverType, string serverName, string user, string pass, string database,
bool writeDbConfigFile)
{
var sConnectionString = GetConnectionString(serverType, serverName, user, pass, database);
XpoDefault.ConnectionString = sConnectionString;
try
{
var s = new Session();
s.Connect();
s.Disconnect();
// Kết nối thành công thì lưu xuống file dbConfig.con
if (writeDbConfigFile)
{
var dbConfigPath = Application.StartupPath + @"\DatabaseConfig.con";
WriteDatabaseConfig(dbConfigPath, serverType, serverName, user, pass, database);
}
}
catch (Exception ex)
{
EasyDialog.ShowErrorDialog("Không kết nối được CSDL (" + ex.Message + ")");
return false;
}
return true;
}
示例3: DisposeShouldNotThrowExceptionWhenConenectHasNotBeenInvoked
public void DisposeShouldNotThrowExceptionWhenConenectHasNotBeenInvoked()
{
var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
var session = new Session(connectionInfo, _serviceFactoryMock.Object);
session.Disconnect();
}
示例4: DisconnectShouldNotThrowExceptionWhenSocketIsNotConnected
public void DisconnectShouldNotThrowExceptionWhenSocketIsNotConnected()
{
var connectionInfo = new ConnectionInfo("localhost", 6767, Resources.USERNAME,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
var session = new Session(connectionInfo, _serviceFactoryMock.Object);
try
{
session.Connect();
Assert.Fail();
}
catch (SocketException)
{
session.Disconnect();
}
}
示例5: AcceptSocket
private void AcceptSocket(IAsyncResult ar)
{
try
{
var socket = _listenser.EndAcceptSocket(ar);
Task.Run(() =>
{
var session = new Session(socket, _hostKey);
session.Disconnected += (ss, ee) => { lock (_lock) _sessions.Remove(session); };
lock (_lock)
_sessions.Add(session);
try
{
if (ConnectionAccepted != null)
ConnectionAccepted(this, session);
session.EstablishConnection();
}
catch (SshConnectionException ex)
{
session.Disconnect(ex.DisconnectReason, ex.Message);
if (ExceptionRasied != null)
ExceptionRasied(this, ex);
}
catch (Exception ex)
{
session.Disconnect();
if (ExceptionRasied != null)
ExceptionRasied(this, ex);
}
});
}
catch
{
}
finally
{
BeginAcceptSocket();
}
}