Files
clever-show/docs/en/api/messaging.md
2020-10-15 15:45:05 +03:00

4.5 KiB

Module lib.messaging

Module functions

get_ip_address

def get_ip_address()

Returns the IP address of current computer or localhost if no network connection present.

Returns:

string: IP address of current computer or `localhost` if no network connection present

message_callback

def message_callback(action_string)

Callback decorator. Functions registered by this decorator will be called upon receiving action message.

Args:

action_string ([type]): [description]

request_callback

def request_callback(string_command)

set_keepalive

def set_keepalive(sock, after_idle_sec=1, interval_sec=3, max_fails=5) -> None

Sets keepalive parameters of given socket.

Args:

sock (socket): socket

after_idle_sec (int, optional): Start sending keepalive packets after this amount of seconds. Defaults to 1.

interval_sec (int, optional): Interval of keepalive packets in seconds. Defaults to 3.

max_fails (int, optional): Count of fails leading to socket disconnect. Defaults to 5.

Raises:

NotImplementedError: for unknown platform

Class ConnectionManager

...

__init__

def __init__(self, whoami='computer')

Initialize self. See help(type(self)) for accurate signature.

close

def close(self)

connect

def connect(self, client_selector, client_socket, client_addr)

get_file

def get_file(self, client_filepath, filepath=None, callback=None, callback_args=(), callback_kwargs=None)

get_response

def get_response(self, requested_value, callback, request_args=(), request_kwargs=None, callback_args=(), callback_kwargs=None)

process_events

def process_events(self, mask)

process_received

def process_received(self, message)

read

def read(self)

send_file

def send_file(self, filepath, dest_filepath)

send_message

def send_message(self, action, args=(), kwargs=None)

write

def write(self)

Class MessageManager

MessageManager class represents single incoming by TCP stream message and contains methods to decode and extract data from incoming data. It also contains static class methods for encoding various types of messages.

Attributes:

income_raw (bytes string) - Append incoming data to this attribute.

content: Would be populated when receiving and processing of the message will be completed. Deafults to None.

__init__

def __init__(self)

Initialize self. See help(type(self)) for accurate signature.

process_message

def process_message(self)

[summary]

Class Namespace

...

__init__

def __init__(self, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Class NotifierSock

...

__init__

def __init__(self)

Initialize self. See help(type(self)) for accurate signature.

close

def close(self)

get_sock

def get_sock(self)

init

def init(self, selector, port=26000)

notify

def notify(self)

process_events

def process_events(self, mask)

Class PendingRequest

...

__init__

def __init__(self, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Class Singleton

...