diff --git a/App.config b/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/App.xaml b/App.xaml
new file mode 100644
index 0000000..d8319ba
--- /dev/null
+++ b/App.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/App.xaml.cs b/App.xaml.cs
new file mode 100644
index 0000000..a066e8f
--- /dev/null
+++ b/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace TcpGameClient
+{
+ ///
+ /// Logica di interazione per App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/MainWindow.xaml b/MainWindow.xaml
new file mode 100644
index 0000000..c1414e9
--- /dev/null
+++ b/MainWindow.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
new file mode 100644
index 0000000..ac0a82b
--- /dev/null
+++ b/MainWindow.xaml.cs
@@ -0,0 +1,238 @@
+/*
+ * Sviluppatore: Pulga Luca;
+ * Classe: 4^L
+ * Data di consegna: 2021/05/17
+ * Scopo: Utilizzando le classi TCPClient e TCPListener realizzare un semplice gioco
+ * (carte, dadi o altro) utilizzando il protocollo TCP (che a differenza dell'UDP
+ * visto oggi richiede la creazione di una connessione).
+ * APP: SPEED CLICKER with TCP protocol
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace TcpGameClient
+{
+ ///
+ /// Logica di interazione per MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ TcpClient client;
+ Socket socket;
+ bool sessionToken;
+ int time = 10000;
+ float cps;
+ int clicks;
+
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ txtDestPort.Text = "55000";
+ txtIpAdd.Text = GetLocalIPAddress();
+ txtTime.Text = "0";
+ }
+
+ private void btnConnect_Click(object sender, RoutedEventArgs e)
+ {
+ ClientSide(); // Ricezione.
+ }
+
+ private async void ClientSide()
+ {
+ try
+ {
+ await Task.Run(() =>
+ {
+ client = new TcpClient("127.0.0.1", 55000);
+ //client.Connect("127.0.0.1", 55000);
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ if (client.Connected) // Controllo se i 2 host sono connessi.
+ {
+ lblConnection.Content = "CONNECTED";
+ btnConnect.IsEnabled = false;
+ }
+ }));
+
+ while (true)
+ {
+ string textToTransmit = "";
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ textToTransmit = lblMine.Content.ToString();
+ }));
+ socket = client.Client; // Parte client.
+
+ byte[] ba = Encoding.ASCII.GetBytes(textToTransmit); // string to byte to send.
+
+
+ byte[] bb = new byte[100];
+ int j = socket.Receive(bb, bb.Length, 0); // Ricezione dati.
+
+ if(j > 0)
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ lblAvversario.Content = "Opponent: " + Encoding.ASCII.GetString(bb);
+ }));
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Errore:\n" + ex.Message, "Client", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ finally
+ {
+ if (client != null)
+ client.Close();
+ }
+ }
+
+ private void Session()
+ {
+ while (true)
+ {
+ if (sessionToken == true)
+ {
+ Thread.Sleep(time);
+ sessionToken = false;
+ cps = time / 1000;
+ cps = clicks / cps;
+
+ string n = "";
+
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ lblMine.Content = "Click: " + clicks.ToString() + ", clicks per second: " + cps.ToString();
+ }));
+
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ n = lblMine.Content.ToString();
+ }));
+
+ Thread.Sleep(100);
+ SendData(n);
+
+ Thread.Sleep(2000);
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ btnStart.Visibility = Visibility.Visible;
+ }));
+ }
+ }
+ }
+
+ ///
+ /// Invio dei dati.
+ ///
+ ///
+ private void SendData(string n)
+ {
+ socket.Send(Encoding.ASCII.GetBytes(n));
+ }
+
+ ///
+ /// Creazione window e avvio thread per gestione click
+ ///
+ ///
+ ///
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ Thread sn = new Thread(Session) { IsBackground = true }; // Se rilascia il button, incremento numero di click.
+ sn.Start();
+ }
+
+ ///
+ /// elease del click del mouse per incremento numero click.
+ ///
+ ///
+ ///
+ private void Window_MouseUp(object sender, MouseButtonEventArgs e)
+ {
+ if (e.LeftButton == MouseButtonState.Released)
+ {
+ clicks++;
+ lblClicks.Content = "Click: " + clicks.ToString();
+ }
+ }
+
+ private void btnStart_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (!int.TryParse(txtTime.Text, out int t))
+ throw new Exception("Inserire un tempo valido.");
+ time = t * 1000;
+ if (sessionToken == false)
+ {
+ clicks = 0;
+ sessionToken = true;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ btnStart.Visibility = Visibility.Hidden;
+ }));
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Errore :\n" + ex.Message, "Client", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ }
+
+ ///
+ /// get automated local ip.
+ ///
+ ///
+ public static string GetLocalIPAddress()
+ {
+ try
+ {
+ string hostName = Dns.GetHostName(); // Retrive the Name of HOST
+ // Get the IP
+ string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get local ip address
+
+ Uri uri = new Uri("http://" + myIP);
+
+ return uri.Host.ToString(); // return dell'ip dell'host.
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("No network adapters with an IPv4 address in the system!");
+ }
+ }
+
+ ///
+ /// control ipv4 address.
+ ///
+ ///
+ ///
+ public static bool IsIPv4(string ipAddress)
+ {
+ return Regex.IsMatch(ipAddress, @"^\d{1,3}(\.\d{1,3}){3}$") && ipAddress.Split('.').SingleOrDefault(s => int.Parse(s) > 255) == null; // Regex per controllare ip.
+ }
+
+ }
+}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b07d5c6
--- /dev/null
+++ b/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// Le informazioni generali relative a un assembly sono controllate dal seguente
+// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
+// associate a un assembly.
+[assembly: AssemblyTitle("TcpGameClient")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TcpGameClient")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
+// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
+// COM, impostare su true l'attributo ComVisible per tale tipo.
+[assembly: ComVisible(false)]
+
+//Per iniziare a creare applicazioni localizzabili, impostare
+//CultureYouAreCodingWith nel file .csproj
+//all'interno di un . Ad esempio, se si utilizza l'inglese (Stati Uniti)
+//nei file di origine, impostare su en-US. Rimuovere quindi il commento dall'attributo
+//NeutralResourceLanguage riportato di seguito. Aggiornare "en-US" nella
+//riga sottostante in modo che corrisponda all'impostazione UICulture nel file di progetto.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //dove si trovano i dizionari delle risorse specifiche del tema
+ //(da usare se nella pagina non viene trovata una risorsa,
+ // oppure nei dizionari delle risorse dell'applicazione)
+ ResourceDictionaryLocation.SourceAssembly //dove si trova il dizionario delle risorse generiche
+ //(da usare se nella pagina non viene trovata una risorsa,
+ // nell'applicazione o nei dizionari delle risorse specifiche del tema)
+)]
+
+
+// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
+//
+// Versione principale
+// Versione secondaria
+// Numero di build
+// Revisione
+//
+// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
+// usando l'asterisco '*' come illustrato di seguito:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..50ebfb3
--- /dev/null
+++ b/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// Codice generato da uno strumento.
+// Versione runtime:4.0.30319.42000
+//
+// Le modifiche apportate a questo file possono causare un comportamento non corretto e andranno perse se
+// il codice viene rigenerato.
+//
+//------------------------------------------------------------------------------
+
+
+namespace TcpGameClient.Properties
+{
+ ///
+ /// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
+ ///
+ // Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder
+ // tramite uno strumento quale ResGen o Visual Studio.
+ // Per aggiungere o rimuovere un membro, modificare il file .ResX, quindi eseguire di nuovo ResGen
+ // con l'opzione /str oppure ricompilare il progetto VS.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Restituisce l'istanza di ResourceManager memorizzata nella cache e usata da questa classe.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TcpGameClient.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte
+ /// le ricerche di risorse che utilizzano questa classe di risorse fortemente tipizzata.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..7fb1b88
--- /dev/null
+++ b/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace TcpGameClient.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TcpGameClient.csproj b/TcpGameClient.csproj
new file mode 100644
index 0000000..4d7a4e0
--- /dev/null
+++ b/TcpGameClient.csproj
@@ -0,0 +1,123 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {04BE0711-E387-4CF4-ADBC-22818E793A44}
+ WinExe
+ TcpGameClient
+ TcpGameClient
+ v4.7.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ icons8_the_flash_sign.ico
+
+
+
+ packages\MaterialDesignColors.2.0.0\lib\net452\MaterialDesignColors.dll
+
+
+ packages\MaterialDesignThemes.4.0.0\lib\net452\MaterialDesignThemes.Wpf.dll
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Questo progetto fa riferimento a uno o più pacchetti NuGet che non sono presenti in questo computer. Usare lo strumento di ripristino dei pacchetti NuGet per scaricarli. Per altre informazioni, vedere http://go.microsoft.com/fwlink/?LinkID=322105. Il file mancante è {0}.
+
+
+
+
\ No newline at end of file
diff --git a/TcpGameClient.sln b/TcpGameClient.sln
new file mode 100644
index 0000000..cf95303
--- /dev/null
+++ b/TcpGameClient.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31205.134
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TcpGameClient", "TcpGameClient.csproj", "{04BE0711-E387-4CF4-ADBC-22818E793A44}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {04BE0711-E387-4CF4-ADBC-22818E793A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {04BE0711-E387-4CF4-ADBC-22818E793A44}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {04BE0711-E387-4CF4-ADBC-22818E793A44}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {04BE0711-E387-4CF4-ADBC-22818E793A44}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F7FDAFCA-A56A-41B8-97A5-E85DBD2035F6}
+ EndGlobalSection
+EndGlobal
diff --git a/TcpGameServer/App.config b/TcpGameServer/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/TcpGameServer/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TcpGameServer/App.xaml b/TcpGameServer/App.xaml
new file mode 100644
index 0000000..bebefd5
--- /dev/null
+++ b/TcpGameServer/App.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TcpGameServer/App.xaml.cs b/TcpGameServer/App.xaml.cs
new file mode 100644
index 0000000..089368c
--- /dev/null
+++ b/TcpGameServer/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace TcpGameServer
+{
+ ///
+ /// Logica di interazione per App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/TcpGameServer/MainWindow.xaml b/TcpGameServer/MainWindow.xaml
new file mode 100644
index 0000000..06caa33
--- /dev/null
+++ b/TcpGameServer/MainWindow.xaml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TcpGameServer/MainWindow.xaml.cs b/TcpGameServer/MainWindow.xaml.cs
new file mode 100644
index 0000000..8b5f970
--- /dev/null
+++ b/TcpGameServer/MainWindow.xaml.cs
@@ -0,0 +1,237 @@
+/*
+ * Sviluppatore: Pulga Luca;
+ * Classe: 4^L
+ * Data di consegna: 2021/05/17
+ * Scopo: Utilizzando le classi TCPClient e TCPListener realizzare un semplice gioco
+ * (carte, dadi o altro) utilizzando il protocollo TCP (che a differenza dell'UDP
+ * visto oggi richiede la creazione di una connessione).
+ * APP: SPEED CLICKER with TCP protocol
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace TcpGameServer
+{
+ ///
+ /// Logica di interazione per MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ bool sessionToken;
+ int time = 10000;
+ float cps;
+ int clicks;
+ IPAddress ipAd;
+ TcpListener myList;
+ Socket s;
+
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ ipAd = IPAddress.Parse("127.0.0.1");
+ myList = new TcpListener(ipAd, 55000);
+
+ txtDestPort.Text = "55000";
+ txtIpAdd.Text = GetLocalIPAddress();
+ }
+
+ private async void ServerSide()
+ {
+ try
+ {
+ await Task.Run(() =>
+ {
+ myList.Start();
+ s = myList.AcceptSocket();
+
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ if (s.Connected) // Controllo se i 2 host sono connessi.
+ {
+ lblConnection.Content = "CONNECTED";
+ btnConnect.IsEnabled = false;
+ }
+ }));
+
+
+ while (true)
+ {
+ byte[] b = new byte[100];
+ string n = "";
+ int k = 0;
+ if (s.Available > 0) // se ci sono byte disponibili, li legge.
+ {
+ k = s.Receive(b); // Ricezione info.
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ lblAvversario.Content = "Opponent: " + Encoding.ASCII.GetString(b);
+ n = lblMine.Content.ToString();
+ }));
+ }
+ }
+
+ });
+
+ myList.Stop();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Errore:\n" + ex.Message, "Server", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ }
+
+ private void btnConnect_Click(object sender, RoutedEventArgs e)
+ {
+ ServerSide(); // Ricezione.
+ }
+
+ private void btnStart_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (!int.TryParse(txtTime.Text, out int t)) // validazione tempo.
+ throw new Exception("Inserire un tempo valido.");
+ time = t * 1000; // tempo in secondi.
+ if (sessionToken == false)
+ {
+ clicks = 0;
+ sessionToken = true;
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ btnStart.Visibility = Visibility.Hidden;
+ }));
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Errore:\n" + ex.Message, "Server", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+ }
+
+ private void Session()
+ {
+ while (true)
+ {
+ if (sessionToken == true)
+ {
+ Thread.Sleep(time);
+ sessionToken = false;
+ // Calcolo click.
+ cps = time / 1000;
+ cps = clicks / cps;
+
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ lblMine.Content = "Click: " + clicks.ToString() + ", clicks per second: " + cps.ToString(); // Info sessione clicker.
+ }));
+
+ string n = "";
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ n = lblMine.Content.ToString();
+ }));
+ Thread.Sleep(100);
+
+ // Se la stringa da inviare non è vuota, allora invio i dati.
+ if(n != "")
+ SendData(n);
+
+ Thread.Sleep(3000);
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ btnStart.Visibility = Visibility.Visible;
+ }));
+
+ }
+ }
+ }
+
+ ///
+ /// Invio dei dati.
+ ///
+ ///
+ private void SendData(string n)
+ {
+ s.Send(Encoding.ASCII.GetBytes(n));
+ }
+
+ ///
+ /// Creazione window e avvio thread per gestione click.
+ ///
+ ///
+ ///
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ Thread sn = new Thread(Session) { IsBackground = true }; // Thread per la gestione dei click e il send della info.
+ sn.Start();
+ }
+
+ ///
+ /// Release del click del mouse per incremento numero click.
+ ///
+ ///
+ ///
+ private void Window_MouseUp(object sender, MouseButtonEventArgs e)
+ {
+ if (e.LeftButton == MouseButtonState.Released) // Se rilascia il button, incremento numero di click.
+ {
+ clicks++;
+ lblClicks.Content = "Click: " + clicks.ToString();
+ }
+ }
+
+ ///
+ /// get automated local ip.
+ ///
+ ///
+ public static string GetLocalIPAddress()
+ {
+ try
+ {
+ string hostName = Dns.GetHostName(); // Retrive the Name of HOST
+ // Get the IP
+ string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get local ip address
+
+ Uri uri = new Uri("http://" + myIP);
+
+ return uri.Host.ToString(); // return dell'ip dell'host.
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("No network adapters with an IPv4 address in the system!");
+ }
+ }
+
+ ///
+ /// control ipv4 address.
+ ///
+ ///
+ ///
+ public static bool IsIPv4(string ipAddress)
+ {
+ return Regex.IsMatch(ipAddress, @"^\d{1,3}(\.\d{1,3}){3}$") && ipAddress.Split('.').SingleOrDefault(s => int.Parse(s) > 255) == null; // Regex per controllare ip.
+ }
+
+ }
+}
diff --git a/TcpGameServer/Properties/AssemblyInfo.cs b/TcpGameServer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..cb1b855
--- /dev/null
+++ b/TcpGameServer/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// Le informazioni generali relative a un assembly sono controllate dal seguente
+// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
+// associate a un assembly.
+[assembly: AssemblyTitle("TcpGameServer")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TcpGameServer")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
+// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
+// COM, impostare su true l'attributo ComVisible per tale tipo.
+[assembly: ComVisible(false)]
+
+//Per iniziare a creare applicazioni localizzabili, impostare
+//CultureYouAreCodingWith nel file .csproj
+//all'interno di un . Ad esempio, se si utilizza l'inglese (Stati Uniti)
+//nei file di origine, impostare su en-US. Rimuovere quindi il commento dall'attributo
+//NeutralResourceLanguage riportato di seguito. Aggiornare "en-US" nella
+//riga sottostante in modo che corrisponda all'impostazione UICulture nel file di progetto.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //dove si trovano i dizionari delle risorse specifiche del tema
+ //(da usare se nella pagina non viene trovata una risorsa,
+ // oppure nei dizionari delle risorse dell'applicazione)
+ ResourceDictionaryLocation.SourceAssembly //dove si trova il dizionario delle risorse generiche
+ //(da usare se nella pagina non viene trovata una risorsa,
+ // nell'applicazione o nei dizionari delle risorse specifiche del tema)
+)]
+
+
+// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
+//
+// Versione principale
+// Versione secondaria
+// Numero di build
+// Revisione
+//
+// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
+// usando l'asterisco '*' come illustrato di seguito:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/TcpGameServer/Properties/Resources.Designer.cs b/TcpGameServer/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..158dd7f
--- /dev/null
+++ b/TcpGameServer/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// Codice generato da uno strumento.
+// Versione runtime:4.0.30319.42000
+//
+// Le modifiche apportate a questo file possono causare un comportamento non corretto e andranno perse se
+// il codice viene rigenerato.
+//
+//------------------------------------------------------------------------------
+
+
+namespace TcpGameServer.Properties
+{
+ ///
+ /// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
+ ///
+ // Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder
+ // tramite uno strumento quale ResGen o Visual Studio.
+ // Per aggiungere o rimuovere un membro, modificare il file .ResX, quindi eseguire di nuovo ResGen
+ // con l'opzione /str oppure ricompilare il progetto VS.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Restituisce l'istanza di ResourceManager memorizzata nella cache e usata da questa classe.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TcpGameServer.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte
+ /// le ricerche di risorse che utilizzano questa classe di risorse fortemente tipizzata.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/TcpGameServer/Properties/Resources.resx b/TcpGameServer/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/TcpGameServer/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TcpGameServer/Properties/Settings.Designer.cs b/TcpGameServer/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..96b7af8
--- /dev/null
+++ b/TcpGameServer/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace TcpGameServer.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/TcpGameServer/Properties/Settings.settings b/TcpGameServer/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/TcpGameServer/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TcpGameServer/TcpGameServer.csproj b/TcpGameServer/TcpGameServer.csproj
new file mode 100644
index 0000000..029f708
--- /dev/null
+++ b/TcpGameServer/TcpGameServer.csproj
@@ -0,0 +1,123 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {6B53B53B-2A67-4BBB-B3F2-41B64FEAA0BC}
+ WinExe
+ TcpGameServer
+ TcpGameServer
+ v4.7.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ icons8_the_flash_sign.ico
+
+
+
+ packages\MaterialDesignColors.2.0.0\lib\net452\MaterialDesignColors.dll
+
+
+ packages\MaterialDesignThemes.4.0.0\lib\net452\MaterialDesignThemes.Wpf.dll
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Questo progetto fa riferimento a uno o più pacchetti NuGet che non sono presenti in questo computer. Usare lo strumento di ripristino dei pacchetti NuGet per scaricarli. Per altre informazioni, vedere http://go.microsoft.com/fwlink/?LinkID=322105. Il file mancante è {0}.
+
+
+
+
\ No newline at end of file
diff --git a/TcpGameServer/TcpGameServer.sln b/TcpGameServer/TcpGameServer.sln
new file mode 100644
index 0000000..ed43908
--- /dev/null
+++ b/TcpGameServer/TcpGameServer.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31205.134
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TcpGameServer", "TcpGameServer.csproj", "{6B53B53B-2A67-4BBB-B3F2-41B64FEAA0BC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6B53B53B-2A67-4BBB-B3F2-41B64FEAA0BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6B53B53B-2A67-4BBB-B3F2-41B64FEAA0BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6B53B53B-2A67-4BBB-B3F2-41B64FEAA0BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6B53B53B-2A67-4BBB-B3F2-41B64FEAA0BC}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {972E4229-DFD3-49B4-B8D9-BC078ABDA236}
+ EndGlobalSection
+EndGlobal
diff --git a/TcpGameServer/icons8_the_flash_sign.ico b/TcpGameServer/icons8_the_flash_sign.ico
new file mode 100644
index 0000000..0be1449
Binary files /dev/null and b/TcpGameServer/icons8_the_flash_sign.ico differ
diff --git a/TcpGameServer/packages.config b/TcpGameServer/packages.config
new file mode 100644
index 0000000..283c7d0
--- /dev/null
+++ b/TcpGameServer/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/TcpGameServer/speed.jpg b/TcpGameServer/speed.jpg
new file mode 100644
index 0000000..09fe365
Binary files /dev/null and b/TcpGameServer/speed.jpg differ
diff --git a/icons8_the_flash_sign.ico b/icons8_the_flash_sign.ico
new file mode 100644
index 0000000..0be1449
Binary files /dev/null and b/icons8_the_flash_sign.ico differ
diff --git a/packages.config b/packages.config
new file mode 100644
index 0000000..283c7d0
--- /dev/null
+++ b/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/speed.jpg b/speed.jpg
new file mode 100644
index 0000000..09fe365
Binary files /dev/null and b/speed.jpg differ