Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NetGroupInfo.cs
Go to the documentation of this file.
1using System;
3
4namespace Terraria.Net;
5
6public class NetGroupInfo
7{
8 public enum InfoProviderId
9 {
11 Steam
12 }
13
14 private interface INetGroupInfoProvider
15 {
17
18 bool HasValidInfo { get; }
19
21 }
22
24 {
25 public InfoProviderId Id => InfoProviderId.IPAddress;
26
27 public bool HasValidInfo => false;
28
30 {
31 return "";
32 }
33 }
34
36 {
38
39 public bool HasValidInfo => Main.LobbyId != 0;
40
42 {
43 return Main.LobbyId.ToString();
44 }
45 }
46
47 private readonly string[] _separatorBetweenInfos = new string[1] { ", " };
48
49 private readonly string[] _separatorBetweenIdAndInfo = new string[1] { ":" };
50
52
59
60 public string ComposeInfo()
61 {
64 {
65 if (infoProvider.HasValidInfo)
66 {
67 string text = (int)infoProvider.Id + _separatorBetweenIdAndInfo[0] + infoProvider.ProvideInfoNeededToJoin();
68 string item = ConvertToSafeInfo(text);
69 list.Add(item);
70 }
71 }
72 return string.Join(_separatorBetweenInfos[0], list.ToArray());
73 }
74
76 {
78 string[] array = info.Split(_separatorBetweenInfos, StringSplitOptions.RemoveEmptyEntries);
79 foreach (string text in array)
80 {
82 if (array2.Length == 2 && int.TryParse(array2[0], out var result))
83 {
84 dictionary[(InfoProviderId)result] = array2[1];
85 }
86 }
87 return dictionary;
88 }
89
90 private string ConvertToSafeInfo(string text)
91 {
93 }
94
95 private string ConvertFromSafeInfo(string text)
96 {
98 }
99}
void Add(TKey key, TValue value)
static string EscapeDataString(string stringToEscape)
Definition Uri.cs:4087
static string UnescapeDataString(string stringToUnescape)
Definition Uri.cs:4058
static ulong LobbyId
Definition Main.cs:389
List< INetGroupInfoProvider > _infoProviders
Dictionary< InfoProviderId, string > DecomposeInfo(string info)
string ConvertToSafeInfo(string text)
readonly string[] _separatorBetweenInfos
readonly string[] _separatorBetweenIdAndInfo
string ConvertFromSafeInfo(string text)