public string GetFriends(string msg, int clientId) { DbMethods dbConnection = new DbMethods(); string username; List <string> activeUsersNames = new List <string>(); lock (activeUsers[clientId]) { if (!activeUsers[clientId].logged) { return(TransmisionProtocol.CreateServerMessage(ErrorCodes.NOT_LOGGED_IN, Options.LOGIN)); } dbConnection = activeUsers[clientId].dbConnection; username = activeUsers[clientId].userName; foreach (User user in activeUsers) { activeUsersNames.Add(user.userName); } } return(TransmisionProtocol.CreateServerMessage(ErrorCodes.NO_ERROR, Options.GET_FRIENDS, dbConnection.GetFriends(username, activeUsersNames))); }