Skip to content

Commit

Permalink
final check
Browse files Browse the repository at this point in the history
  • Loading branch information
haelime committed Apr 15, 2024
1 parent eb24f09 commit 2dc320c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions include/Server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#include <sys/event.h>
#include <sys/socket.h>
#include <unistd.h>
#include <cassert>

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <cstring>
#include <cstdlib>

#include "defines.hpp"
#include "ClientData.hpp"
Expand Down
2 changes: 1 addition & 1 deletion srcs/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Message Channel::getNameReply(sockaddr_in *serverAddr , const ClientData *
names += "@";
names += it->first + " ";
}
names.pop_back();
names.erase(names.length()-1, 1);
reply.mMessageTokens.push_back(names);
return reply;
}
Expand Down
4 changes: 3 additions & 1 deletion srcs/Logger.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <cassert>

#include "Logger.hpp"

// There is A LOT to REFACTOR here.
Expand All @@ -16,7 +18,7 @@ void Logger::setFileLogging(const std::string& fileName)
{
mIsFileLogging = true;
mFileName = fileName;
logFile.open(mFileName, std::ios::out | std::ios::app);
logFile.open(mFileName.c_str(), std::ios::out | std::ios::app);
if (logFile.fail())
{
Logger::log(ERROR, "Failed to open log file, logging on console only");
Expand Down
15 changes: 10 additions & 5 deletions srcs/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ bool Server::initServer(int argc, char** argv)
// mServerAddress.sin_addr.s_addr = INADDR_ANY;
mServerAddress.sin_port = htons(mPort);
mServerAddress.sin_family = AF_INET;
mServerAddress.sin_len = sizeof(mServerAddress);
mServerAddressLength = mServerAddress.sin_len;
// mServerAddress.sin_len = sizeof(mServerAddress);
// mServerAddressLength = mServerAddress.sin_len;

// Bind listen socket
Logger::log(DEBUG, "Server is binding socket...");
if (SOCKET_ERROR == bind(mServerListenSocket, (const sockaddr*)&mServerAddress,
mServerAddressLength))
sizeof(mServerAddress)))
{
Logger::log(ERROR, "Failed to bind socket");
Logger::log(ERROR, "Probably port is already in use");
Expand Down Expand Up @@ -2336,7 +2336,12 @@ void Server::executeParsedMessages(ClientData* clientData)
break;

case 'l':
channel->setUserLimit(std::stoi(modeParams));
for (size_t i = 0; i< modeParams.length(); i++)
{
if (!isdigit(modeParams[i]))
return;
}
channel->setUserLimit(std::atoi(modeParams.c_str()));
break;

default:
Expand Down Expand Up @@ -3228,7 +3233,7 @@ void Server::sendWelcomeMessageToClientData(ClientData* clientData)
successMessageToClient.mMessageTokens.push_back(RPL_CREATED);
successMessageToClient.mMessageTokens.push_back(clientData->getClientNickname());
std::string timeNow = std::ctime(&mServerStartTime);
timeNow.pop_back();
timeNow.erase(timeNow.length()-1, 1);
successMessageToClient.mMessageTokens.push_back(":This server was created " + timeNow);
clientData->getServerToClientSendQueue().push(successMessageToClient);
}
Expand Down

0 comments on commit 2dc320c

Please sign in to comment.