|
11 | 11 | using System.Buffers.Binary;
|
12 | 12 | using System.Collections.Generic;
|
13 | 13 | using System.Linq;
|
14 |
| -using System.Threading; |
15 | 14 | using System.Threading.Tasks;
|
16 | 15 | using TSLib.Audio;
|
17 | 16 | using TSLib.Commands;
|
@@ -41,16 +40,16 @@ public sealed partial class TsFullClient : TsBaseFunctions, IAudioActiveProducer
|
41 | 40 | public ClientId ClientId => packetHandler.ClientId;
|
42 | 41 | /// <summary>The disonnect message when leaving.</summary>
|
43 | 42 | public string QuitMessage { get; set; } = "Disconnected";
|
44 |
| - /// <summary>The <see cref="Full.VersionSign"/> used to connect.</summary> |
45 |
| - public VersionSign VersionSign => connectionDataFull.VersionSign; |
46 |
| - /// <summary>The <see cref="Full.IdentityData"/> used to connect.</summary> |
| 43 | + /// <summary>The <see cref="TsVersionSigned"/> used to connect.</summary> |
| 44 | + public TsVersionSigned VersionSign => connectionDataFull.VersionSign; |
| 45 | + /// <summary>The <see cref="IdentityData"/> used to connect.</summary> |
47 | 46 | public IdentityData Identity => connectionDataFull.Identity;
|
48 | 47 | private TsClientStatus status;
|
49 | 48 | public override bool Connected { get { lock (statusLock) return status == TsClientStatus.Connected; } }
|
50 | 49 | public override bool Connecting { get { lock (statusLock) return status == TsClientStatus.Connecting; } }
|
51 | 50 | protected override Deserializer Deserializer => msgProc.Deserializer;
|
52 | 51 | private ConnectionDataFull connectionDataFull;
|
53 |
| - public Connection Book { get; set; } = new Connection(); |
| 52 | + public Connection Book { get; } = new Connection(); |
54 | 53 |
|
55 | 54 | public override event EventHandler<DisconnectEventArgs>? OnDisconnected;
|
56 | 55 | public event EventHandler<CommandError>? OnErrorEvent;
|
@@ -80,15 +79,18 @@ public override async Task Connect(ConnectionData conData)
|
80 | 79 | if (!(conData is ConnectionDataFull conDataFull)) throw new ArgumentException($"Use the {nameof(ConnectionDataFull)} derivative to connect with the full client.", nameof(conData));
|
81 | 80 | if (conDataFull.Identity is null) throw new ArgumentNullException(nameof(conDataFull.Identity));
|
82 | 81 | if (conDataFull.VersionSign is null) throw new ArgumentNullException(nameof(conDataFull.VersionSign));
|
83 |
| - connectionDataFull = conDataFull; |
84 |
| - ConnectionData = conData; |
85 | 82 |
|
86 | 83 | await Disconnect();
|
87 | 84 |
|
88 | 85 | remoteAddress = await TsDnsResolver.TryResolve(conData.Address);
|
89 | 86 | if (remoteAddress is null)
|
90 | 87 | throw new TsException("Could not read or resolve address.");
|
91 | 88 |
|
| 89 | + connectionDataFull = conDataFull; |
| 90 | + ConnectionData = conData; |
| 91 | + ServerConstants = TsConst.Default; |
| 92 | + Book.Reset(); |
| 93 | + |
92 | 94 | var ctx = new ConnectionContext { WasExit = false };
|
93 | 95 | lock (statusLock)
|
94 | 96 | {
|
@@ -249,6 +251,9 @@ async partial void ProcessEachInitIvExpand2(InitIvExpand2 initIvExpand2)
|
249 | 251 | partial void ProcessEachInitServer(InitServer initServer)
|
250 | 252 | {
|
251 | 253 | packetHandler.ClientId = initServer.ClientId;
|
| 254 | + var serverVersion = TsVersion.TryParse(initServer.ServerVersion, initServer.ServerPlatform); |
| 255 | + if (serverVersion != null) |
| 256 | + ServerConstants = TsConst.GetByServerBuildNum(serverVersion.Build); |
252 | 257 |
|
253 | 258 | lock (statusLock)
|
254 | 259 | status = TsClientStatus.Connected;
|
@@ -474,11 +479,11 @@ public Task ClientEk(string ek, string proof)
|
474 | 479 |
|
475 | 480 | public Task ClientInit(string nickname, bool inputHardware, bool outputHardware,
|
476 | 481 | string defaultChannel, string defaultChannelPassword, string serverPassword, string metaData,
|
477 |
| - string nicknamePhonetic, string defaultToken, string hwid, VersionSign versionSign) |
| 482 | + string nicknamePhonetic, string defaultToken, string hwid, TsVersionSigned versionSign) |
478 | 483 | => SendNoResponsed(new TsCommand("clientinit") {
|
479 | 484 | { "client_nickname", nickname },
|
480 |
| - { "client_version", versionSign.Name }, |
481 |
| - { "client_platform", versionSign.PlatformName }, |
| 485 | + { "client_version", versionSign.Version }, |
| 486 | + { "client_platform", versionSign.Platform }, |
482 | 487 | { "client_input_hardware", inputHardware },
|
483 | 488 | { "client_output_hardware", outputHardware },
|
484 | 489 | { "client_default_channel", defaultChannel },
|
|
0 commit comments