📄 tcpconnectivitytester.cs
字号:
namespace Imps.Client.CommLayer.TcpSipConnection
{
using Imps.Client.Base;
using Imps.Client.CommLayer;
using Imps.Client.Core;
using Imps.Client.Resource;
using System;
using System.Threading;
internal class TcpConnectivityTester
{
private readonly TestConnectionCallBack _callback;
private readonly Imps.Client.CommLayer.TcpSipConnection.TcpSipConnection _connection;
private readonly ConnectionManagerImp _connectionManager;
private readonly SipCRegAction _reg1;
private readonly Imps.Client.Core.User _user;
public TcpConnectivityTester(Imps.Client.Core.User user, Imps.Client.CommLayer.TcpSipConnection.TcpSipConnection connection, ConnectionManagerImp connectionManager, TestConnectionCallBack callback)
{
this._user = user;
this._connection = connection;
this._connectionManager = connectionManager;
this._callback = callback;
this._reg1 = new SipCRegAction(this._user, null);
}
public void DoTest()
{
ThreadPool.QueueUserWorkItem(new WaitCallback(this.InnerTest));
}
private void InnerTest(object o)
{
this._reg1.Execute(new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.Reg1FinalResponseReceived), new EventHandler<FailedEventArgs>(this, (IntPtr) this.Reg1SendMessageFailed), new EventHandler(this.Reg1WaitResponseTimeout), this._connection, true);
}
private void Reg1FinalResponseReceived(object sender, SipResponseReceivedEventArgs e)
{
this._connectionManager.DoTcpTestSuccessed = true;
this.SetWaitEvent();
ConnectionManagerImp.DoCallBack(this._callback, TestConnectionStatus.Successed, StringTable.NetworkSettingOption.TestConnectionSuccessed);
ConnectionManagerImp.DoCallBack(this._callback, TestConnectionStatus.Successed, StringTable.NetworkSettingOption.TestConnectionAllSuccessed);
}
private void Reg1SendMessageFailed(object sender, FailedEventArgs e)
{
this._connectionManager.DoTcpTestSuccessed = false;
this.SetWaitEvent();
}
private void Reg1WaitResponseTimeout(object sender, EventArgs e)
{
this._connectionManager.DoTcpTestSuccessed = false;
this.SetWaitEvent();
}
private void SetWaitEvent()
{
this._reg1.WaitRegResult.Set();
this._connection.Close();
this._connectionManager.TcpTestWaitEvent.Set();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -