diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs
index 3f0cd33..69f9f1b 100644
--- a/ClientApp/Utils/Client.cs
+++ b/ClientApp/Utils/Client.cs
@@ -139,12 +139,12 @@ namespace ClientApp.Utils
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());
+ Debug.WriteLine("stop");
break;
case DataParser.SET_RESISTANCE:
Console.WriteLine("Set resistance identifier");
@@ -181,7 +181,7 @@ namespace ClientApp.Utils
/// starts sending a message to the server
///
/// the message to send
- private void sendMessage(byte[] message)
+ public void sendMessage(byte[] message)
{
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), 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();
diff --git a/DoctorApp/Utils/Client.cs b/DoctorApp/Utils/Client.cs
index 668315b..757f99c 100644
--- a/DoctorApp/Utils/Client.cs
+++ b/DoctorApp/Utils/Client.cs
@@ -116,7 +116,7 @@ namespace DoctorApp.Utils
this.MainViewModel.NewConnectedUser(DataParser.getUsernameFromResponseJson(payloadbytes));
break;
case DataParser.DISCONNECT:
- this.MainViewModel.NewConnectedUser(DataParser.getUsernameFromResponseJson(payloadbytes));
+ this.MainViewModel.DisconnectedUser(DataParser.getUsernameFromResponseJson(payloadbytes));
break;
default:
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
@@ -140,7 +140,7 @@ namespace DoctorApp.Utils
/// starts sending a message to the server
///
/// the message to send
- private void sendMessage(byte[] message)
+ public void sendMessage(byte[] message)
{
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
}
@@ -170,7 +170,7 @@ namespace DoctorApp.Utils
string hashPassword = Util.Hasher.HashString(password);
- byte[] message = DataParser.getJsonMessage(DataParser.LoginAsDoctor(username, hashPassword));
+ byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(username, hashPassword));
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
diff --git a/DoctorApp/ViewModels/ClientInfoViewModel.cs b/DoctorApp/ViewModels/ClientInfoViewModel.cs
index 54d2df0..c40f6ea 100644
--- a/DoctorApp/ViewModels/ClientInfoViewModel.cs
+++ b/DoctorApp/ViewModels/ClientInfoViewModel.cs
@@ -1,13 +1,81 @@
-using System;
+using DoctorApp.Utils;
+using GalaSoft.MvvmLight.Command;
+using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
using System.Text;
+using System.Windows.Controls;
+using System.Windows.Input;
+using Util;
namespace DoctorApp.ViewModels
{
- class ClientInfoViewModel
+ class ClientInfoViewModel : ObservableObject
{
+ public ObservableCollection ChatLog { get; set; }
public string Username { get; set; }
- public string TabName { get; set; }
+
+ public string Status { get; set; }
+
+ public int Speed { get; set; }
+
+ public int BPM { get; set; }
+
+ public int Resistance { get; set; }
+ public int Acc_Power { get; set; }
+
+ public int Curr_Power { get; set; }
+
+ public int Distance { get; set; }
+
+ public ICommand StartSession { get; set; }
+
+ public ICommand StopSession { get; set; }
+
+ public ICommand Chat { get; set; }
+
+ public ICommand ChatToAll { get; set; }
+
+ public ICommand ClientInfo { get; set; }
+
+ public ICommand SetResistance { get; set; }
+
+ public MainWindowViewModel MainWindowViewModel { get; set; }
+ private Client client;
+
+ public ClientInfoViewModel(MainWindowViewModel mainWindowViewModel)
+ {
+ MainWindowViewModel = mainWindowViewModel;
+ ChatLog = new ObservableCollection();
+ client = mainWindowViewModel.client;
+
+ StartSession = new RelayCommand(()=>{
+ client.sendMessage(DataParser.getStartSessionJson(Username));
+ Status = "Session started";
+ });
+
+ StopSession = new RelayCommand(() => {
+ client.sendMessage(DataParser.getStopSessionJson(Username));
+ Status = "Session stopped, waiting to start again.";
+ });
+
+ Chat = new RelayCommand