Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/27/08 17:05:05 (16 years ago)
Author:
msteinbi
Message:

Login implemented with db (#399)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r838 r842  
    77using HeuristicLab.Hive.Contracts;
    88using HeuristicLab.Core;
     9using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
     10using System.Resources;
     11using System.Reflection;
    912
    1013namespace HeuristicLab.Hive.Server.Core {
     
    1720    int nrOfJobs = 1;
    1821
     22    IClientAdapter clientAdapter;
     23    ResourceManager rm;
     24
    1925    public ClientCommunicator() {
     26      clientAdapter = ServiceLocator.GetClientAdapter();
     27      rm = new ResourceManager("HiveServerMessages.resx", Assembly.GetExecutingAssembly());
     28
    2029      jobs = new LinkedList<long>();
    2130      for (long i = 0; i < nrOfJobs; i++) {
     
    2736
    2837    public Response Login(ClientInfo clientInfo) {
    29       if (clients == null)
    30         clients = new List<ClientInfo>();
    31 
    32       clients.Add(clientInfo);
    33 
    3438      Response response = new Response();
    3539      response.Success = true;
    36       response.StatusMessage = "Client with GUID " + clientInfo.ClientId + " successuflly logged in";
     40
     41      ICollection<ClientInfo> allClients = clientAdapter.GetAllClients();
     42      foreach (ClientInfo client in allClients) {
     43        if (client.ClientId.Equals(clientInfo.ClientId)) {
     44          if (client.State != State.offline) {
     45            response.Success = false;
     46            response.StatusMessage = rm.GetString("UserAllreadyOnline");
     47            break;
     48          } else
     49            break; // searching for clients can be stopped, because it was found and it's state is offline
     50        }
     51      }
     52
     53      if (response.Success) {
     54        clientAdapter.UpdateClient(clientInfo);
     55        response.Success = true;
     56        response.StatusMessage = rm.GetString("LoginSuccess");
     57      }
    3758
    3859      return response;
Note: See TracChangeset for help on using the changeset viewer.