Develop #10
@@ -150,7 +150,7 @@ namespace DoctorApp.Utils
|
|||||||
/// starts sending a message to the server
|
/// starts sending a message to the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">the message to send</param>
|
/// <param name="message">the message to send</param>
|
||||||
private void sendMessage(byte[] message)
|
public void sendMessage(byte[] message)
|
||||||
{
|
{
|
||||||
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
||||||
}
|
}
|
||||||
@@ -234,10 +234,10 @@ namespace DoctorApp.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void tryLogin(string username, string password)
|
public void tryLogin(string username, string password)
|
||||||
{
|
{
|
||||||
|
string hashUser = Hasher.HashString(username);
|
||||||
|
string hashPassword = Hasher.HashString(password);
|
||||||
|
|
||||||
string hashPassword = Util.Hasher.HashString(password);
|
byte[] message = DataParser.getJsonMessage(DataParser.GetLoginJson(hashUser, hashPassword));
|
||||||
|
|
||||||
byte[] message = DataParser.getJsonMessage(DataParser.LoginAsDoctor(username, hashPassword));
|
|
||||||
|
|
||||||
|
|
||||||
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
using System;
|
using DoctorApp.Utils;
|
||||||
|
using GalaSoft.MvvmLight.Command;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using Util;
|
||||||
|
|
||||||
namespace DoctorApp.ViewModels
|
namespace DoctorApp.ViewModels
|
||||||
{
|
{
|
||||||
@@ -9,5 +13,43 @@ namespace DoctorApp.ViewModels
|
|||||||
{
|
{
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { 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;
|
||||||
|
client = mainWindowViewModel.client;
|
||||||
|
|
||||||
|
StartSession = new RelayCommand(()=>{
|
||||||
|
client.sendMessage(DataParser.getStartSessionJson());
|
||||||
|
});
|
||||||
|
|
||||||
|
StopSession = new RelayCommand(() => {
|
||||||
|
client.sendMessage(DataParser.getStopSessionJson());
|
||||||
|
});
|
||||||
|
Chat = new RelayCommand<object>((parameter) =>
|
||||||
|
{
|
||||||
|
/*client.sendMessage(DataParser.)*/
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ namespace DoctorApp.ViewModels
|
|||||||
{
|
{
|
||||||
App.Current.Dispatcher.Invoke((Action)delegate
|
App.Current.Dispatcher.Invoke((Action)delegate
|
||||||
{
|
{
|
||||||
Tabs.Add(new ClientInfoViewModel
|
Tabs.Add(new ClientInfoViewModel(MainWindowViewModel)
|
||||||
{
|
{
|
||||||
Username = username,
|
Username = username,
|
||||||
|
Status = "Waiting to start"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,17 @@ namespace Util
|
|||||||
return ((dynamic)JsonConvert.DeserializeObject(Encoding.ASCII.GetString(json))).data.username;
|
return ((dynamic)JsonConvert.DeserializeObject(Encoding.ASCII.GetString(json))).data.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*public static bool getChatMessageFronJson(byte[] json, out string username, out string chat)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
dynamic jsn = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(json));
|
||||||
|
username = jsn.data.username;
|
||||||
|
chat = jsn.data.chat;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user