|
plptools
|
Responsible for orchestrating the high-level life cycle of a daemon-side NCP server and multiplexing connections over a single hardware comms channel (serial port, etc). More...
#include <ncpsession.h>

Public Member Functions | |
| NCPSession (int portNumber, int baudRate, std::string host, std::string serialDevice, bool autoexit, bool noDSRCheck, unsigned short nverbose, NCPStatusCallback statusCallback=nullptr, void *callbackContext=nullptr) | |
| NCPSession (const NCPSession &)=delete | |
| NCPSession & | operator= (const NCPSession &)=delete |
| ~NCPSession () | |
| int | start () |
| Creates and manages all the threads necessary to run a full session for communicating with a Psion and exposing that to clients via the a TCP socket. More... | |
| void | cancel () |
| Mark the session as cancelled. More... | |
| void | wait () |
| Wait for the session to terminate. More... | |
Private Member Functions | |
| bool | isCancelled () |
Private Attributes | |
| int | portNumber_ |
| int | baudRate_ |
| std::string | host_ |
| std::string | serialDevice_ |
| bool | autoexit_ |
| bool | noDSRCheck_ |
| unsigned short | nverbose_ |
| NCPStatusCallback | statusCallback_ |
| void * | callbackContext_ |
| pthread_t | sessionMainThreadId_ = 0 |
| NCP * | ncp_ = nullptr |
| NCP instance. More... | |
| IOWatch | socketChannelWatch_ |
| Used to watch all active SocketChannel instances (stored in socketChannels_) to see if they're readable. More... | |
| TCPSocket | skt_ |
| std::mutex | socketChannelLock_ |
| std::vector< SocketChannel * > | socketChannels_ |
| int | cancellationPipe_ [2] = { -1, -1 } |
Friends | |
| void * | ncp_session_main_thread (void *arg) |
| void * | link_thread (void *arg) |
| void * | socket_connection_polling_thread (void *arg) |
| Responsible for driving the SocketChannel instances (incoming TCP connections) by means of SocketChannel::socketPoll. More... | |
| void | check_for_new_socket_connection (NCPSession *session) |
Responsible for orchestrating the high-level life cycle of a daemon-side NCP server and multiplexing connections over a single hardware comms channel (serial port, etc).
Creates and manages three threads (ncp_session_main_thread, link_thread, and socket_connection_polling_thread) that drive the serial ports, accept incoming TCP connections from clients, and poll connected TCP sockets.
Definition at line 42 of file ncpsession.h.
|
inline |
Definition at line 45 of file ncpsession.h.
|
delete |
| NCPSession::~NCPSession | ( | ) |
Definition at line 218 of file ncpsession.cc.
| void NCPSession::cancel | ( | ) |
Mark the session as cancelled.
It is anticipated that this method be called from within an interrupt handler in CLI apps. When using cancel to initiate session shutdown, it should be paired with wait.
Definition at line 235 of file ncpsession.cc.
|
private |
Definition at line 240 of file ncpsession.cc.
|
delete |
| int NCPSession::start | ( | ) |
Creates and manages all the threads necessary to run a full session for communicating with a Psion and exposing that to clients via the a TCP socket.
This is a non-blocking function. The session should be stopped by calling stop or cancelling the session using cancel interrupting the session thread with SIGINT.
Definition at line 225 of file ncpsession.cc.
| void NCPSession::wait | ( | ) |
Wait for the session to terminate.
A typical usage pattern might call stop, followed by, wait to ensure the session is fully terminated and cleaned up before doing further work (e.g., starting a new session with a different configuration).
Definition at line 251 of file ncpsession.cc.
|
friend |
Definition at line 123 of file ncpsession.cc.
|
friend |
The NCP::reset call here is currently required (even though it feels like it shouldn't be) as it's responsible for preparing the stack after a successful connection has ended (DataLink currently has responsibility for performing internal resets when auto-detecting baud rate).
Definition at line 51 of file ncpsession.cc.
|
friend |
Definition at line 171 of file ncpsession.cc.
|
friend |
Responsible for driving the SocketChannel instances (incoming TCP connections) by means of SocketChannel::socketPoll.
This isn't likely to scale particularly well as it polls all connected sockets whenever a single one wakes up, but it seems to work (as we never have that many connected clients).
Definition at line 78 of file ncpsession.cc.
|
private |
Definition at line 111 of file ncpsession.h.
|
private |
Definition at line 108 of file ncpsession.h.
|
private |
Definition at line 115 of file ncpsession.h.
|
private |
Definition at line 134 of file ncpsession.h.
|
private |
Definition at line 109 of file ncpsession.h.
|
private |
NCP instance.
Definition at line 124 of file ncpsession.h.
|
private |
Definition at line 112 of file ncpsession.h.
|
private |
Definition at line 113 of file ncpsession.h.
|
private |
Definition at line 107 of file ncpsession.h.
|
private |
Definition at line 110 of file ncpsession.h.
|
private |
Definition at line 119 of file ncpsession.h.
|
private |
Definition at line 131 of file ncpsession.h.
|
private |
Definition at line 132 of file ncpsession.h.
|
private |
Definition at line 133 of file ncpsession.h.
|
private |
Used to watch all active SocketChannel instances (stored in socketChannels_) to see if they're readable.
Definition at line 129 of file ncpsession.h.
|
private |
Definition at line 114 of file ncpsession.h.