public static void Run(RequestWithHeader <JobHeader> jr) { // After the JobHeader the master will send the job OrderReciever.RecieveJob(jr); // Register job StorageProvider.GetInstance().MasterRegisteredJob(jr); }
public static void Run(RequestWithHeader <FinishedOrderHeader> foh) { Log.Warning(foh.header.Message); if (foh.header.Size == 0) { Log.Warning(foh.header.Message); return; } OrderReciever.RecieveFinishedOrder(foh); }
/// <summary> /// Runs the logic for Client Hello /// </summary> /// <param name="ch"><see cref="ClientHello"/></param> public static void Run(RequestWithHeader <ClientHelloHeader> ch) { #if DEBUG Tuple <string, bool> auth = new Tuple <string, bool>("", true); #else Tuple <string, bool> auth = Authentification.AuthenticateClient(ch.header.ClientIP, ch.header.ClientToken); #endif string sha = ""; bool aproval = false; if (auth.Item2 == true) { aproval = DecideAproval(ch.header); if (aproval == false) { Log.Warning("Order was not approved, fetching already existing sha!"); sha = GetExistingSha(ch.header); auth = new Tuple <string, bool>("Error: Existing order with sha:" + sha, false); } else { sha = CreateSha(ch.header); Log.Information("Order was approved, new sha :{0}", sha); } } if (auth.Item1.Contains("Token:")) { StorageProvider.GetInstance().RegisterClientToken(ch.header.ClientIP, auth.Item1.Split(':')[1]); } // Wrap the ServerHello Header WraperHeader wraper = new WraperHeader { Type = HeaderTypes.ServerHelloHeader, Data = ByteArrayUtils.ToByteArray(CreateServerHelloHeader(aproval, sha, auth.Item1)) }; Sender.Send(wraper, ch.Client); // Wait for the orderpost if (aproval == true) { OrderReciever.ReicieveClientHello(ch, sha); } // If aproval is false, the connection will close }
public static void Run(RequestWithHeader <JobResultHeader> jr) { OrderReciever.RecieveFinishedJob(jr); }