-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed session classes in server. Implemented client base.
- Loading branch information
Showing
14 changed files
with
171 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
# Temporary ignored while not complited | ||
client/ | ||
CMakeList.txt | ||
makefile | ||
simple_lib/include/simple_lib/message.cpp | ||
|
||
# C++ build files and directories | ||
## C++ build files and directories | ||
build/ | ||
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "MainConsole.hpp" | ||
|
||
#include <sys/eventfd.h> | ||
|
||
#include <errno.h> | ||
#include <unistd.h> | ||
|
||
namespace simpleApp | ||
{ | ||
MainConsole::MainConsole() | ||
{ | ||
|
||
} | ||
|
||
MainConsole::~MainConsole() | ||
{ | ||
if (this->breakEventFd != -1) | ||
close(this->breakEventFd); | ||
} | ||
|
||
int MainConsole::initBreak() | ||
{ | ||
if (this->breakEventFd != -1) | ||
close(this->breakEventFd); | ||
|
||
this->breakEventFd = eventfd(0, EFD_NONBLOCK); | ||
|
||
return this->breakEventFd == -1 ? errno : 0; | ||
} | ||
|
||
int MainConsole::raiseBreak() | ||
{ | ||
if (this->breakEventFd != -1) | ||
{ | ||
if (eventfd_write(this->breakEventFd, static_cast<eventfd_t>(1)) == -1) | ||
return errno; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int MainConsole::consoleLoop() | ||
{ | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
namespace simpleApp | ||
{ | ||
class MainConsole | ||
{ | ||
public: | ||
MainConsole(); | ||
~MainConsole(); | ||
|
||
int initBreak(); | ||
int raiseBreak(); | ||
int consoleLoop(); | ||
private: | ||
int breakEventFd = -1; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <iostream> | ||
|
||
#include <signal.h> | ||
|
||
#include "MainConsole.hpp" | ||
|
||
simpleApp::MainConsole console = simpleApp::MainConsole(); | ||
|
||
void onBreak(int s) | ||
{ | ||
int err = console.raiseBreak(); | ||
|
||
if(err != 0) | ||
std::cout << "Break event trigger failed with code " << err << std::endl; | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
std::cout << "Welcome to the Simple Client! For exit press Ctrl+C" << std::endl; | ||
|
||
int err = console.initBreak(); | ||
if (err != 0) | ||
{ | ||
std::cout << "Break event initialization failed with code " << err << std::endl; | ||
return -1; | ||
} | ||
|
||
struct sigaction sigIntHandler; | ||
|
||
sigIntHandler.sa_handler = onBreak; | ||
sigemptyset(&sigIntHandler.sa_mask); | ||
sigIntHandler.sa_flags = 0; | ||
|
||
if(sigaction(SIGINT, &sigIntHandler, NULL) == -1) | ||
{ | ||
std::cout << "Break event configuration failed with code " << errno << std::endl; | ||
return -1; | ||
} | ||
|
||
return console.consoleLoop(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.