我尝试使用TS3QueryLib连接到Teamspeak3。但是我得到了错误信息:套接字错误!错误代码:超时。此外,不可能在服务器的连接字符串中添加密码。
using TS3QueryLib.Core;
using TS3QueryLib.Core.Common;
using TS3QueryLib.Core.Common.Responses;
using TS3QueryLib.Core.Communication;
using TS3QueryLib.Core.Server;
using TS3QueryLib.Core.Server.Responses;
那是连接功能:
public void Connect()
{
// do not connect when already connected or during connection establishing
if (QueryDispatcher != null)
return;
if (string.IsNullOrWhiteSpace(ServerAddressTextBox.Text))
{
MessageBox.Show("Please provide a server address!");
return;
}
ushort port;
if (!ushort.TryParse(ServerPort.Text, out port))
{
MessageBox.Show("Please provide a valid query port!");
return;
}
UpdateUI(ConnectionState.Connecting);
QueryDispatcher = new AsyncTcpDispatcher(ServerAddressTextBox.Text.Trim(), port);
QueryDispatcher.BanDetected += QueryDispatcher_BanDetected;
QueryDispatcher.ReadyForSendingCommands += QueryDispatcher_ReadyForSendingCommands;
QueryDispatcher.ServerClosedConnection += QueryDispatcher_ServerClosedConnection;
QueryDispatcher.SocketError += QueryDispatcher_SocketError;
QueryDispatcher.Connect();
}