Bugfixes
This commit is contained in:
@@ -22,7 +22,7 @@ namespace ErgometerLibrary
|
||||
string[] existingSessions = Directory.GetDirectories(DataFolder);
|
||||
|
||||
Random rand = new Random();
|
||||
int sessionID = rand.Next(int.MinValue, int.MaxValue);
|
||||
int sessionID = rand.Next(0, int.MaxValue);
|
||||
|
||||
|
||||
while (existingSessions.Contains(sessionID.ToString()))
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace ErgometerLibrary
|
||||
ChatMessage = chat;
|
||||
}
|
||||
|
||||
public NetCommand(string name, bool doctor, int session)
|
||||
public NetCommand(string name, bool doctor, string password, int session)
|
||||
{
|
||||
Type = CommandType.LOGIN;
|
||||
Session = session;
|
||||
@@ -60,12 +60,16 @@ namespace ErgometerLibrary
|
||||
|
||||
DisplayName = name;
|
||||
IsDoctor = doctor;
|
||||
Password = password;
|
||||
}
|
||||
|
||||
public static NetCommand Parse(string command)
|
||||
{
|
||||
string[] com = command.Split('»');
|
||||
|
||||
Console.WriteLine(command);
|
||||
Console.WriteLine(com[0]);
|
||||
|
||||
int comType = int.Parse(com[0]);
|
||||
int session = 0;
|
||||
if (com[1].StartsWith("ses"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
@@ -9,33 +10,56 @@ namespace ErgometerLibrary
|
||||
{
|
||||
public static void SendNetCommand(TcpClient client, NetCommand command)
|
||||
{
|
||||
byte[] b = Encoding.ASCII.GetBytes(command.ToString());
|
||||
/*
|
||||
byte[] b = Encoding.Unicode.GetBytes(command.ToString());
|
||||
client.GetStream().Write(b, 0, b.Length);
|
||||
client.GetStream().Flush();
|
||||
*/
|
||||
SendString(client, command.ToString());
|
||||
}
|
||||
|
||||
public static void SendString(TcpClient client, string command)
|
||||
{
|
||||
byte[] b = Encoding.ASCII.GetBytes(command);
|
||||
/*
|
||||
byte[] b = Encoding.Unicode.GetBytes(command);
|
||||
client.GetStream().Write(b, 0, b.Length);
|
||||
client.GetStream().Flush();
|
||||
*/
|
||||
|
||||
StreamWriter wr = new StreamWriter(client.GetStream(), Encoding.Unicode);
|
||||
wr.WriteLine(command);
|
||||
Console.WriteLine("sent " + command);
|
||||
wr.Flush();
|
||||
}
|
||||
|
||||
public static NetCommand ReadNetCommand(TcpClient client)
|
||||
{
|
||||
/*
|
||||
byte[] bytesFrom = new byte[(int) client.ReceiveBufferSize];
|
||||
client.GetStream().Read(bytesFrom, 0, (int)client.ReceiveBufferSize);
|
||||
string response = Encoding.ASCII.GetString(bytesFrom);
|
||||
string response = Encoding.Unicode.GetString(bytesFrom);
|
||||
NetCommand net = NetCommand.Parse(response);
|
||||
return net;
|
||||
*/
|
||||
|
||||
string str = ReadString(client);
|
||||
NetCommand net = NetCommand.Parse(str);
|
||||
return net;
|
||||
}
|
||||
|
||||
public static string ReadString(TcpClient client)
|
||||
{
|
||||
/*
|
||||
byte[] bytesFrom = new byte[(int)client.ReceiveBufferSize];
|
||||
client.GetStream().Read(bytesFrom, 0, (int)client.ReceiveBufferSize);
|
||||
string response = Encoding.ASCII.GetString(bytesFrom);
|
||||
string response = Encoding.Unicode.GetString(bytesFrom);
|
||||
return response;
|
||||
*/
|
||||
|
||||
StreamReader rd = new StreamReader(client.GetStream(), Encoding.Unicode);
|
||||
string str = rd.ReadLine();
|
||||
Console.WriteLine("rec " + str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static IPAddress GetIP(string ipstring)
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.2.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.2.1")]
|
||||
[assembly: AssemblyVersion("1.0.2.2")]
|
||||
[assembly: AssemblyFileVersion("1.0.2.2")]
|
||||
|
||||
Reference in New Issue
Block a user