some optimizations
This commit is contained in:
1 parent
b959c5ff8a
commit
80b54cad25
7 files changed
+33
-38
No files matched your search
@@ -115,7 +115,7 @@ namespace ClientServerLib
|
||||
connected = true;
|
||||
RaiseOnConnectionChanged();
|
||||
}
|
||||
catch (Exception e)
|
||||
catch
|
||||
{
|
||||
connected = false;
|
||||
RaiseOnConnectionChanged();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Keys>(CommandSendKeyEvent, Key);
|
||||
}
|
||||
|
||||
public static bool DecodeCommandSendKeyEvent(byte[] Message, out Keys Key)
|
||||
{
|
||||
return TryDeserialize<Keys>(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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -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:
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
</Reference>
|
||||
<Reference Include="ClientServerLib">
|
||||
<HintPath>..\ClientServerLib\ClientServerLib\bin\ClientServerLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Community.CsharpSqlite">
|
||||
<HintPath>..\Output\Community.CsharpSqlite.dll</HintPath>
|
||||
|
||||
Reference in new issue
Block a user