- Timestamp:
- 11/19/08 17:03:25 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Contracts/ResponseHB.cs
r780 r783 7 7 namespace HeuristicLab.Hive.Contracts { 8 8 9 /// <summary>10 /// If a client sends a heartbeat the server can request sereral actions11 /// actions:12 /// - jobReady: an new Job is ready to be calculated13 /// - jobSnapshot: send a snapshot of the current status of the calculated job14 /// - abortJobwithReturn: abort the job and return all existing results15 /// - abortJobwithoutReturn: abort the job and don't send back anything16 /// - nothingToDo: there is nothing to do at the moment17 /// </summary>18 public enum Action { jobReady, jobSnapshot, abortJobwithReturn, abortJobwithoutReturn, nothingToDo }19 9 20 10 /// <summary> … … 24 14 [DataContract] 25 15 public class ResponseHB : Response { 26 /// <summary>27 /// The server can send more than one actionRequest to the client28 /// So they are stored in one Map29 /// key [long]: JobId30 /// value [Action]: action31 /// </summary>32 16 [DataMember] 33 public Dictionary<long, Action> ActionRequest { get; set; }17 public List<MessageContainer> ActionRequest { get; set; } 34 18 } 35 19 } -
trunk/sources/HeuristicLab.Hive.Contracts/ResponseJob.cs
r780 r783 15 15 public class ResponseJob : Response { 16 16 [DataMember] 17 public Job Job{ get; set; }17 public long JobId { get; set; } 18 18 } 19 19 } -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r780 r783 12 12 /// </summary> 13 13 public class ClientCommunicator: IClientCommunicator { 14 List<Client> clients; 15 List<long> jobs; 16 int nrOfJobs = 10; 17 18 public ClientCommunicator() { 19 jobs = new List<long>(); 20 for (int i = 1; i < nrOfJobs; i++) { 21 jobs.Add(i); 22 } 23 } 24 14 25 #region IClientCommunicator Members 15 26 16 27 public Response Login(Client clientInfo) { 28 if (clients == null) 29 clients = new List<Client>(); 30 31 clients.Add(clientInfo); 32 17 33 Response response = new Response(); 18 34 response.Success = true; 19 response.StatusMessage = " Logged in...";35 response.StatusMessage = "Client with GUID " + clientInfo.ClientId + " successuflly logged in"; 20 36 21 37 return response; … … 23 39 24 40 public ResponseHB SendHeartBeat(HeartBeatData hbData) { 25 throw new NotImplementedException(); 41 ResponseHB response = new ResponseHB(); 42 43 response.Success = true; 44 response.StatusMessage = "HeartBeat received"; 45 if (jobs.Count > 0) 46 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob)); 47 else 48 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage)); 49 50 return response; 26 51 } 27 52 28 53 public ResponseJob PullJob(Guid clientId) { 29 throw new NotImplementedException(); 54 ResponseJob response = new ResponseJob(); 55 56 response.JobId = jobs.ElementAt(jobs.Count); 57 response.Success = true; 58 response.StatusMessage = "Job with id " + jobs.Count + " sent"; 59 jobs.Remove(jobs.Count); 60 61 return response; 30 62 } 31 63 32 64 public Response SendJobResult(JobResult Result, bool finished) { 33 throw new NotImplementedException(); 65 Response response = new Response(); 66 response.Success = true; 67 response.StatusMessage = "Thanks for calculating"; 68 69 return response; 34 70 } 35 71 36 72 public Response Logout(Guid clientId) { 37 throw new NotImplementedException(); 73 bool clientRemoved = false; 74 foreach (Client client in clients) { 75 if (client.ClientId.Equals(clientId)) { 76 clients.Remove(client); 77 clientRemoved = true; 78 } 79 } 80 Response response = new Response() 81 82 if (clientRemoved) { 83 response.Success = true; 84 response.StatusMessage = "Successfully logged out. Good bye"; 85 } else { 86 response.Success = false; 87 response.StatusMessage = "Sorry, but you weren't logged in"; 88 } 89 return response; 38 90 } 39 91
Note: See TracChangeset
for help on using the changeset viewer.