Changeset 783 for trunk/sources/HeuristicLab.Hive.Server.Core
- Timestamp:
- 11/19/08 17:03:25 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.