Develop #10
@@ -135,17 +135,17 @@ namespace ClientApp.Utils
|
||||
Debug.WriteLine($"login failed \"{responseStatus}\"");
|
||||
}
|
||||
break;
|
||||
/*case DataParser.START_SESSION:
|
||||
case DataParser.START_SESSION:
|
||||
Console.WriteLine("Session started!");
|
||||
this.sessionRunning = true;
|
||||
if (engineConnection.Connected && !engineConnection.FollowingRoute) engineConnection.StartRouteFollow();
|
||||
sendMessage(DataParser.getStartSessionJson());
|
||||
Debug.WriteLine("start");
|
||||
break;
|
||||
case DataParser.STOP_SESSION:
|
||||
Console.WriteLine("Stop session identifier");
|
||||
this.sessionRunning = false;
|
||||
sendMessage(DataParser.getStopSessionJson());
|
||||
break;*/
|
||||
Debug.WriteLine("stop");
|
||||
break;
|
||||
case DataParser.SET_RESISTANCE:
|
||||
Console.WriteLine("Set resistance identifier");
|
||||
if (this.handler == null)
|
||||
@@ -297,6 +297,7 @@ namespace ClientApp.Utils
|
||||
public void Dispose()
|
||||
{
|
||||
Debug.WriteLine("client dispose called");
|
||||
sendMessage(DataParser.getDisconnectJson(LoginViewModel.Username));
|
||||
this.stream.Dispose();
|
||||
this.client.Dispose();
|
||||
this.handler.stop();
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace ClientApp.ViewModels
|
||||
|
||||
this.InfoModel = new Info();
|
||||
this.client = client;
|
||||
loginViewModel = new LoginViewModel(this);
|
||||
LoginViewModel loginViewModel = new LoginViewModel(this);
|
||||
SelectedViewModel = loginViewModel;
|
||||
this.client.SetLoginViewModel(loginViewModel);
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace DoctorApp.Utils
|
||||
|
||||
string hashPassword = Util.Hasher.HashString(password);
|
||||
|
||||
byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(hashUser, hashPassword));
|
||||
byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(username, hashPassword));
|
||||
|
||||
|
||||
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
||||
|
||||
@@ -69,11 +69,6 @@ namespace DoctorApp.ViewModels
|
||||
|
||||
//TODO RelayCommand ChatToAll
|
||||
|
||||
ClientInfo = new RelayCommand(() =>
|
||||
{
|
||||
//TODO POPUP
|
||||
});
|
||||
|
||||
SetResistance = new RelayCommand<object>((parameter) =>
|
||||
{
|
||||
client.sendMessage(DataParser.getSetResistanceJson(Username, float.Parse(((TextBox)parameter).Text)));
|
||||
|
||||
@@ -63,6 +63,5 @@
|
||||
<Button Content="Set Resistance" Grid.Column="1" HorizontalAlignment="Left" Margin="187,128,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Height="18" Command="{Binding SetResistance}" CommandParameter="{Binding ElementName=textBox_SetResistance}"/>
|
||||
<Canvas Grid.Row="3" Background="White" Margin="0,33,0,0"/>
|
||||
<ComboBox Name="DropBox" HorizontalAlignment="Left" Margin="0,6,0,0" Grid.Row="3" VerticalAlignment="Top" Width="190"/>
|
||||
<Button Content="Client Info" Grid.Column="1" HorizontalAlignment="Left" Margin="207,6,0,0" VerticalAlignment="Top" Height="26" Width="82"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:DoctorApp"
|
||||
mc:Ignorable="d"
|
||||
Background="Transparent"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Window.Resources>
|
||||
<Style TargetType="{x:Type local:MainWindow}">
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using ClientApp.Utils;
|
||||
using System.Diagnostics;
|
||||
using Util;
|
||||
|
||||
@@ -110,10 +109,10 @@ namespace Server
|
||||
}
|
||||
break;
|
||||
case DataParser.START_SESSION:
|
||||
this.saveData = new SaveData(Directory.GetCurrentDirectory() + "/" + this.username + "/" + sessionStart.ToString("yyyy-MM-dd HH-mm-ss"));
|
||||
this.communication.StartSessionUser(DataParser.getUsernameFromJson(payloadbytes));
|
||||
break;
|
||||
case DataParser.STOP_SESSION:
|
||||
this.saveData = null;
|
||||
this.communication.StopSessionUser(DataParser.getUsernameFromJson(payloadbytes));
|
||||
break;
|
||||
case DataParser.SET_RESISTANCE:
|
||||
bool worked = DataParser.getResistanceFromResponseJson(payloadbytes);
|
||||
@@ -242,5 +241,15 @@ namespace Server
|
||||
hex.AppendFormat("{0:x2}", b);
|
||||
return hex.ToString();
|
||||
}
|
||||
|
||||
public void StartSession()
|
||||
{
|
||||
this.saveData = new SaveData(Directory.GetCurrentDirectory() + "/" + this.username + "/" + sessionStart.ToString("yyyy-MM-dd HH-mm-ss"));
|
||||
}
|
||||
|
||||
public void StopSession()
|
||||
{
|
||||
this.saveData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.IO.Pipes;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using DoctorApp.Utils;
|
||||
using Util;
|
||||
|
||||
namespace Server
|
||||
@@ -56,5 +55,30 @@ namespace Server
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void StartSessionUser(string user)
|
||||
{
|
||||
foreach(Client client in clients)
|
||||
{
|
||||
if(client.username == user)
|
||||
{
|
||||
client.sendMessage(DataParser.getStartSessionJson(user));
|
||||
client.StartSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopSessionUser(string user)
|
||||
{
|
||||
foreach (Client client in clients)
|
||||
{
|
||||
if (client.username == user)
|
||||
{
|
||||
client.sendMessage(DataParser.getStopSessionJson(user));
|
||||
client.StopSession();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user