16 #ifndef DABC_SocketCommandChannel
17 #define DABC_SocketCommandChannel
19 #ifndef DABC_SocketThread
146 void CloseClient(
bool iserr =
false,
const char* msg = 0);
156 const std::string &hostname =
"",
#define DABC_REFERENCE(RefClass, ParentClass, T)
Reference on memory from memory pool.
Represents command with its arguments.
Reference on the arbitrary object
Special addon class for handling of socket and socket events.
@ evntSocketLastInfo
last system event, used by sockets
Provides command channel to the dabc process.
SocketCommandClientRef ProvideWorker(const std::string &remnodename, double conn_tmout=-1)
Provide client for remote node.
SocketCommandChannel(const std::string &name, SocketServerAddon *connaddon, Command cmd)
bool fClientsAllowed
when true, incomming clients are allowed
virtual std::string RequiredThrdClass() const
As name said, command channel requires socket thread for the work.
virtual int PreviewCommand(Command cmd)
This method called before command will be executed.
std::string fRedirectDevice
name of socket device, which can get redirection
int fClientCnt
counter for new clients
std::string GetRemoteNode(const std::string &url)
Provide string for connection to remote node.
virtual ~SocketCommandChannel()
virtual double ProcessTimeout(double last_diff)
timeout used in channel to update node hierarchy, which than can be requested from remote
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
int fNodeId
current node id
Client side of command connection between two nodes.
dabc::Buffer fSendRawData
raw data, which should be send with command
void SendSubmittedCommands()
Send submitted commands to remote.
bool EnsureRecvBuffer(unsigned strsize)
CommandsQueue fSendQueue
queue to keep commands which should be send
CommandsQueue fWaitQueue
commands which should be replied from remote
std::string fRemoteName
name of connection, appeared in the browser
void ProcessRecvPacket()
Method called, when complete packet (header + raw data) is received.
virtual void OnThreadAssigned()
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
bool ExecuteCommandByItself(Command cmd)
@ stConnecting
initial state, worker waits until channel is connected
@ stWorking
normal state when execution of different commands are done
@ stFailure
failure is detected and connection will be close
@ stClosing
socket connection going normally down
virtual double ProcessTimeout(double last_diff)
unsigned fRecvBufSize
currently allocated size of recv buffer
dabc::Buffer fSendBuf
content of transported command
double ExtraServerTimeout() const
EState fState
current state of the worker
void AddCommand(dabc::Command cmd, bool asreply=false)
Submit command to send queue, if queue is empty start sending immediately.
bool fRemoteObserver
if true, channel automatically used to update information from remote
SocketCommandClient(Reference parent, const std::string &name, SocketAddon *addon, const std::string &hostname="", double reconnect=0.)
virtual void ProcessEvent(const EventId &)
SocketCmdPacket fSendHdr
header for send command
@ kindReply
reply (server -> client)
@ kindDisconnect
close of connection (client -> server)
@ kindCommand
command (client -> server)
@ kindCancel
cancel cmd execution (server -> client)
ERecvState fRecvState
state that happens with receiver (server)
CommandsQueue fCmds
commands to be submitted to the remote
void CloseClient(bool iserr=false, const char *msg=0)
Called when connection must be closed due to the error.
virtual bool ReplyCommand(Command cmd)
Reimplement this method to react on command reply Return true if command can be destroyed by framewor...
char * fRecvBuf
raw buffer for receiving command
virtual ~SocketCommandClient()
double fReconnectPeriod
interval how often reconnect will be tried
std::string fClientNameSufix
name suffix, which will be append to name seen on the server side
void SendCommand(dabc::Command cmd, bool asreply=false)
Send next command to the remote.
SocketCmdPacket fRecvHdr
buffer for receiving header
double ExtraClientTimeout() const
bool fSendingActive
indicate if currently send active
std::string fRemoteHostName
host name and port number
Socket addon for handling connection requests on server side.
Reference on dabc::Worker
Active object, which is working inside dabc::Thread.
const char * typeSocketThread
Event structure, exchanged between DABC threads.
Defines syntax of raw packet, transformed on the command channels.
uint32_t data_kind
kind of data inside packet
uint32_t data_timeout
timeout in milliseconds, 0 - not timeout at all
uint32_t data_cmdsize
which part of data is for command in xml format
uint32_t dabc_header
constant, which identifies dabc packet
uint32_t data_size
total length of the information in the packet
uint32_t data_rawsize
which part of data at the end is raw data