public ToxOptions([NotNull] IToxOptions other) : this() { this.Ipv6Enabled = other.Ipv6Enabled; this.UdpEnabled = other.UdpEnabled; this.LocalDiscoveryEnabled = other.LocalDiscoveryEnabled; this.ProxyType = other.ProxyType; this.ProxyHost = other.ProxyHost; this.ProxyPort = other.ProxyPort; this.StartPort = other.StartPort; this.EndPort = other.EndPort; this.TcpPort = other.TcpPort; this.HolePunchingEnabled = other.HolePunchingEnabled; }
static void Main(string[] args) { using (IToxOptions options = ToxOptions.Default()) using (ITox tox = options.Create()) { tox.OnFriendRequestReceived += OnFriendRequestReceived; tox.OnFriendMessageReceived += OnFriendMessageReceived; tox.OnConnectionStatusChanged += Tox_OnConnectionStatusChanged; foreach (ToxNode node in Nodes) { tox.Bootstrap(node, out _); } tox.Name = "SharpTox"; tox.StatusMessage = "Testing SharpTox"; using (ToxLoop.Start(tox)) { Console.WriteLine($"ID: {tox.Id}"); Console.ReadKey(); } void OnFriendMessageReceived(object sender, ToxEventArgs.FriendMessageEventArgs e) { //get the name associated with the friendnumber string name = tox.GetFriendName(e.FriendNumber, out _); //print the message to the console Console.WriteLine("<{0}> {1}", name, e.Message); } void OnFriendRequestReceived(object sender, ToxEventArgs.FriendRequestEventArgs e) { //automatically accept every friend request we receive tox.AddFriendNoRequest(e.PublicKey, out _); } } }