NAME

Net::Clacks::Client - client for CLACKS interprocess messaging

SYNOPSIS

use Net::Clacks::Client;

DESCRIPTION

This implements the client network protocol for the CLACKS interprocess messaging. This is used a lot in PageCamel projects to let different processes (workers, webgui, PageCamelSVC) communicate with each other

new

Create a new instance.

newSocket

Create a new instance, but use a Unix domain socket instead of tcp/ip

init

Internal function

reconnect

Reconnect to the CLACKS server when something went wrong.

getRawSocket

Returns the raw socket. You MUST NOT send or read data from because this will mess up the connection. Access to the raw socket is only useful in speciality cases, like you want to wait on multiple Clacks sockets for incoming data using IO::Select. In most cases, you wont need this.

doNetwork

Process incoming and outpoing messages. doNetwork tries to send as much as possible. But due to network congestion it might not be able to send everything in one go and it will try not to hold up the caller for too long. Thats why it's important to call doNetwork from the cyclic loop of your programm at least every few seconds or so (depending on what you are trying to do).

doNetwork takes one optional argument, the timeout time to wait for incoming traffic. The default is not to wait at all.

flush

Send everything in the client out queue to the server and wait for a confirmation from the server it has recieved everything. This is a syncronous operation and will hold up the calling program.

ping

Send a PING (keepalive) packet.

disablePing

Temporarly disable auto-disconnects by the server (NOPING command). Useful before doing something with indeterminate length (long running functions and such).

notify

NOTIFY other clients via CLACKS that an event happened.

set

SET a value for a CLACKS variable to other clients.

listen

LISTEN to specific NOTIFY and SET events.

unlisten

Stop listening to specific NOTIFY and SET events.

store

STORE a value in clacks for later retrieval.

retrieve

RETRIEVE a values from clacks that has been stored earlier.

increment

INCREMENT a stored value by one. Takes an optional argument to say how much to increment.

decrement

DECREMENT a stored value by one. Takes an optional argument to say how much to decrement.

remove

REMOVE/DELETE a stored key from clacks

keylist

Get a list of all keys stored in clacks.

clearcache

Remove all keys stored in clacks.

setAndStore

Meta-function that both calls set() and store() internally with a single library call. Useful in some circumstances when you both want to remember the variable and also tell everyone interested immediately that it has changed.

setMonitormode

Enable/Disable monitor mode. When enabled, the server sends all events it sees as DEBUG events (events LISTENed to also get send the normal way).

getServerinfo

Get server name and version.

getNext

Get the next incoming event in the queue.

clientlist

Get a list of all clients connected to the server. If the server is using interclacks (multiple servers in a pool), it will only list the clients connected to the server you are connected to.

sendRawCommand

Adds whatever you want to the out queue, to be send to the server. This is mostly useful when debugging and/or enhancing your server or if you want to implement a command line shell to your clacks server-

activate_memcached_compat

This activates a sort of memcached compatibility setup. Don't use this directly, it's an internal wonky workaround. Use Net::Clacks::ClacksCache instead.

autohandle_messages

This is also part of the internal memcached compatibility setup. Don't use this directly.

disconnect

Tries to send all remaining data in the output buffers and then disconnect cleanly from the server. Of course, if the connection already has gone the way of the dodo, any chance of cleanly disconnecting has already passed.

DESTROY

This tries to close the connection cleanly but there is a good chance it wont succeed under certain circumstances, especially on program exit. Use disconnect() before exiting your program for a better controlled behaviour.

IMPORTANT NOTE

Please make sure and read the documentations for Net::Clacks as it contains important information pertaining to upgrades and general changes!

AUTHOR

Rene Schickbauer, <cavac@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008-2020 Rene Schickbauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.