diff --git a/ClientServerLib/ClientServerLib/CClient.cs b/ClientServerLib/ClientServerLib/CClient.cs index fe8b4a58..36804951 100644 --- a/ClientServerLib/ClientServerLib/CClient.cs +++ b/ClientServerLib/ClientServerLib/CClient.cs @@ -115,7 +115,7 @@ namespace ClientServerLib connected = true; RaiseOnConnectionChanged(); } - catch (Exception e) + catch { connected = false; RaiseOnConnectionChanged(); diff --git a/ClientServerLib/ClientServerLib/CConnection.cs b/ClientServerLib/ClientServerLib/CConnection.cs index 900a4366..b1b7b1d3 100644 --- a/ClientServerLib/ClientServerLib/CConnection.cs +++ b/ClientServerLib/ClientServerLib/CConnection.cs @@ -71,7 +71,7 @@ namespace ClientServerLib if (Data == null || !keySet) return Data; - using (Aes aes = Aes.Create()) + using (Aes aes = new AesManaged()) { aes.Key = dh.Key; aes.GenerateIV(); @@ -117,7 +117,7 @@ namespace ClientServerLib Array.Copy(Data, 4, IV, 0, 16); int dataLength = BitConverter.ToInt32(Data, 20); - using (Aes aes = Aes.Create()) + using (Aes aes = new AesManaged()) { aes.Key = dh.Key; aes.IV = IV; diff --git a/ClientServerLib/ClientServerLib/Vocaluxe/CCommands.cs b/ClientServerLib/ClientServerLib/Vocaluxe/CCommands.cs index cec22606..274d49b0 100644 --- a/ClientServerLib/ClientServerLib/Vocaluxe/CCommands.cs +++ b/ClientServerLib/ClientServerLib/Vocaluxe/CCommands.cs @@ -6,7 +6,6 @@ using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; using System.Text; using System.Security.Cryptography; -using System.Windows.Forms; namespace Vocaluxe.Base.Server @@ -24,8 +23,11 @@ namespace Vocaluxe.Base.Server public const int ResponseLoginOK = 23; - public const int CommandSendKeyEvent = 100; - public const int CommandSendKeyStroke = 101; + public const int CommandSendKeyStroke = 100; + public const int CommandSendKeyUp = 110; + public const int CommandSendKeyDown = 111; + public const int CommandSendKeyLeft = 112; + public const int CommandSendKeyRight = 113; public const int CommandSendMouseMoveEvent = 200; public const int CommandSendMouseLBDownEvent = 220; @@ -59,15 +61,7 @@ namespace Vocaluxe.Base.Server #endregion Login #region Keyboard - public static byte[] CreateCommandSendKeyEvent(Keys Key) - { - return Serialize(CommandSendKeyEvent, Key); - } - public static bool DecodeCommandSendKeyEvent(byte[] Message, out Keys Key) - { - return TryDeserialize(Message, out Key); - } #endregion Keyboard @@ -109,7 +103,7 @@ namespace Vocaluxe.Base.Server obj = (T)formatter.Deserialize(ms); return true; } - catch (Exception) + catch (Exception e) { return false; } diff --git a/ClientServerLib/ClientTest/ClientTest.cs b/ClientServerLib/ClientTest/ClientTest.cs index 50d9f4db..e05f9705 100644 --- a/ClientServerLib/ClientTest/ClientTest.cs +++ b/ClientServerLib/ClientTest/ClientTest.cs @@ -32,14 +32,6 @@ namespace ClientTest base.OnClosing(e); } - private void OnKeyDown(object sender, KeyEventArgs e) - { - if (!client.Connected || !loggedIn) - return; - - client.SendMessage(CCommands.CreateCommandSendKeyEvent(e.KeyCode), null); - } - private void btConnect_Click(object sender, EventArgs e) { if (!client.Connected) @@ -185,7 +177,7 @@ namespace ClientTest if (!client.Connected || !loggedIn) return; - client.SendMessage(CCommands.CreateCommandSendKeyEvent(Keys.Up), null); + client.SendMessage(CCommands.CreateCommandWithoutParams(CCommands.CommandSendKeyUp), null); } private void btLeft_Click(object sender, EventArgs e) @@ -193,7 +185,7 @@ namespace ClientTest if (!client.Connected || !loggedIn) return; - client.SendMessage(CCommands.CreateCommandSendKeyEvent(Keys.Left), null); + client.SendMessage(CCommands.CreateCommandWithoutParams(CCommands.CommandSendKeyLeft), null); } private void btDown_Click(object sender, EventArgs e) @@ -201,7 +193,7 @@ namespace ClientTest if (!client.Connected || !loggedIn) return; - client.SendMessage(CCommands.CreateCommandSendKeyEvent(Keys.Down), null); + client.SendMessage(CCommands.CreateCommandWithoutParams(CCommands.CommandSendKeyDown), null); } private void brRight_Click(object sender, EventArgs e) @@ -209,7 +201,7 @@ namespace ClientTest if (!client.Connected || !loggedIn) return; - client.SendMessage(CCommands.CreateCommandSendKeyEvent(Keys.Right), null); + client.SendMessage(CCommands.CreateCommandWithoutParams(CCommands.CommandSendKeyRight), null); } } } diff --git a/Output/ClientServerLib.dll b/Output/ClientServerLib.dll index 23dc72c2..13f422d8 100644 Binary files a/Output/ClientServerLib.dll and b/Output/ClientServerLib.dll differ diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index 7407e42a..17dff97c 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -58,7 +58,7 @@ namespace Vocaluxe.Base.Server } int command = BitConverter.ToInt32(Message, 0); - byte[] answer = null; + byte[] answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseNOK); ; switch (command) { @@ -84,19 +84,27 @@ namespace Vocaluxe.Base.Server if (!loggedIn) return answer; - + switch (command) { - case CCommands.CommandSendKeyEvent: - Keys key; - if (!CCommands.DecodeCommandSendKeyEvent(Message, out key)) - answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseNOK); - else - { - answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK); - } + case CCommands.CommandSendKeyUp: + answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK); + Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Up)); + break; - Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, key)); + case CCommands.CommandSendKeyDown: + answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK); + Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Down)); + break; + + case CCommands.CommandSendKeyLeft: + answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK); + Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Left)); + break; + + case CCommands.CommandSendKeyRight: + answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK); + Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Right)); break; default: diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 2ed45688..e7bb3d74 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -154,6 +154,7 @@ ..\ClientServerLib\ClientServerLib\bin\ClientServerLib.dll + True ..\Output\Community.CsharpSqlite.dll