Added broadcast

This commit is contained in:
2015-10-20 19:40:45 +02:00
parent 232639e3e2
commit b75083be83
2 changed files with 28 additions and 4 deletions
+26 -2
View File
@@ -9,7 +9,7 @@ namespace ErgometerLibrary
{
public class NetCommand
{
public enum CommandType { LOGIN, DATA, CHAT, LOGOUT, SESSION, VALUESET, USER, RESPONSE, REQUEST, LENGTH, SESSIONDATA, ERROR }
public enum CommandType { LOGIN, DATA, CHAT, LOGOUT, SESSION, VALUESET, USER, RESPONSE, REQUEST, LENGTH, SESSIONDATA, ERROR, BROADCAST }
public enum RequestType { USERS, ALLSESSIONS, OLDDATA, SESSIONDATA, CHAT }
public enum ResponseType { LOGINOK, LOGINWRONG, ERROR, NOTLOGGEDIN }
public enum ValueType { TIME, POWER, ENERGY, DISTANCE }
@@ -104,6 +104,16 @@ namespace ErgometerLibrary
ChatMessage = chat.Replace("\n", "");
}
//BROADCAST
public NetCommand(string broadcast, int session)
{
Type = CommandType.BROADCAST;
Session = session;
Timestamp = Helper.Now;
ChatMessage = broadcast.Replace("\n", "");
}
//SETVALUE
public NetCommand(ValueType value, int val, int session)
{
@@ -184,11 +194,23 @@ namespace ErgometerLibrary
return ParseLength(session, args);
case 11:
return ParseSessionData(session, args);
case 12:
return ParseBroadcast(session, args);
default:
throw new FormatException("Error in NetCommand: " + comType + " is not a valid command type.");
}
}
private static NetCommand ParseBroadcast(int session, string[] args)
{
if (args.Length != 1)
throw new MissingFieldException("Error in NetCommand: Broadcast Message is missing arguments");
NetCommand temp = new NetCommand(args[0], session);
return temp;
}
private static NetCommand ParseSessionData(int session, string[] args)
{
if (args.Length != 2)
@@ -384,7 +406,9 @@ namespace ErgometerLibrary
break;
case CommandType.SESSIONDATA:
command += "11»ses" + Session + "»" + DisplayName + "»" + Timestamp;
Console.WriteLine("Lib: " + command);
break;
case CommandType.BROADCAST:
command += "12»ses" + Session + "»" + ChatMessage;
break;
case CommandType.ERROR:
command += "ERROR IN NETCOMMAND";
+2 -2
View File
@@ -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.3.5")]
[assembly: AssemblyFileVersion("1.0.3.5")]
[assembly: AssemblyVersion("1.0.3.6")]
[assembly: AssemblyFileVersion("1.0.3.6")]