本文整理匯總了C#中Quobject.SocketIoClientDotNet.Client.Socket.Disconnect方法的典型用法代碼示例。如果您正苦於以下問題:C# Socket.Disconnect方法的具體用法?C# Socket.Disconnect怎麽用?C# Socket.Disconnect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Quobject.SocketIoClientDotNet.Client.Socket
的用法示例。
在下文中一共展示了Socket.Disconnect方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Connect
public void Connect()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
ManualResetEvent = new ManualResetEvent(false);
var options = CreateOptions();
var uri = CreateUri();
socket = IO.Socket(uri, options);
socket.On(Socket.EVENT_CONNECT, () =>
{
log.Info("EVENT_CONNECT");
socket.Disconnect();
});
socket.On(Socket.EVENT_DISCONNECT,
(data) =>
{
log.Info("EVENT_DISCONNECT");
Message = (string) data;
ManualResetEvent.Set();
});
//socket.Open();
ManualResetEvent.WaitOne();
socket.Close();
Assert.Equal("io client disconnect", this.Message);
}
示例2: ShouldNotTryToReconnectWithIncorrectPortWhenReconnectionDisabled
public void ShouldNotTryToReconnectWithIncorrectPortWhenReconnectionDisabled()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
ManualResetEvent = new ManualResetEvent(false);
Flag = false;
var options = CreateOptions();
options.Reconnection = false;
var uri = "http://localhost:3940";
var manager = new Manager(new Uri(uri), options);
socket = manager.Socket("/invalid");
manager.On(Manager.EVENT_RECONNECT_ATTEMPT, () =>
{
Flag = true;
});
manager.On(Manager.EVENT_CONNECT_ERROR, async () =>
{
// set a timeout to let reconnection possibly fire
log.Info("EVENT_CONNECT_ERROR");
await Task.Delay(1000);
ManualResetEvent.Set();
});
ManualResetEvent.WaitOne();
log.Info("after WaitOne");
socket.Disconnect();
manager.Close();
Assert.False(Flag);
}
示例3: ShouldTryToReconnectTwiceAndFailWhenRequestedTwoAttemptsWithIncorrectAddressAndReconnectEnabled
public void ShouldTryToReconnectTwiceAndFailWhenRequestedTwoAttemptsWithIncorrectAddressAndReconnectEnabled()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
ManualResetEvent = new ManualResetEvent(false);
Flag = false;
var reconnects = 0;
var options = CreateOptions();
options.Reconnection = true;
options.ReconnectionAttempts = 2;
options.ReconnectionDelay = 10;
var uri = "http://localhost:3940";
var manager = new Manager(new Uri(uri), options);
socket = manager.Socket("/asd");
manager.On(Manager.EVENT_RECONNECT_ATTEMPT, () =>
{
log.Info("EVENT_RECONNECT_ATTEMPT");
reconnects++;
});
manager.On(Manager.EVENT_RECONNECT_FAILED, () =>
{
log.Info("EVENT_RECONNECT_FAILED");
Flag = true;
socket.Disconnect();
manager.Close();
ManualResetEvent.Set();
});
ManualResetEvent.WaitOne();
Assert.Equal(2, reconnects);
}
示例4: ShouldReconnectByDefault
public async Task ShouldReconnectByDefault()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
ManualResetEvent = new ManualResetEvent(false);
Flag = false;
var options = CreateOptions();
var uri = CreateUri();
var manager = new Manager(new Uri(uri), options);
socket = manager.Socket("/");
manager.On(Socket.EVENT_RECONNECT, () =>
{
log.Info("EVENT_RECONNECT");
Flag = true;
socket.Disconnect();
ManualResetEvent.Set();
});
await Task.Delay(500);
log.Info("before EngineSocket close");
manager.EngineSocket.Close();
ManualResetEvent.WaitOne();
Assert.True(Flag);
}
示例5: ShouldOpenANewNamespaceAfterConnectionGetsClosed
public void ShouldOpenANewNamespaceAfterConnectionGetsClosed()
{
var log = LogManager.GetLogger(Global.CallerName());
log.Info("Start");
ManualResetEvent = new ManualResetEvent(false);
Flag = false;
var options = CreateOptions();
var uri = CreateUri();
var manager = new Manager(new Uri(uri), options);
socket = manager.Socket("/");
socket.On(Socket.EVENT_CONNECT, () =>
{
socket.Disconnect();
});
socket.On(Socket.EVENT_DISCONNECT, () =>
{
var foo = manager.Socket("/foo");
foo.On(Socket.EVENT_CONNECT, () =>
{
Flag = true;
foo.Disconnect();
socket.Disconnect();
manager.Close();
ManualResetEvent.Set();
});
foo.Open();
});
ManualResetEvent.WaitOne();
Assert.True(Flag);
}