TDLib v0.0.2 TDLib View Source
This module allow you to interact with and manage sessions.
Link to this section Summary
Functions
Close the session identified by session_name
Configuration template for TDLib, to be modified and used as parameter of
open/3
Open a new session. Spawns a new instance of tdlib-json-cli
Transmit a message over the session identified by session_name
Set the process receiving the incoming update for session
session_name
to client_pid
. The incoming messages can be handled with
def handle_info({:recv, msg}, state), do: ...
using GenServer
Link to this section Functions
Close the session identified by session_name
.
Configuration template for TDLib, to be modified and used as parameter of
open/3
.
See TDLib.Object.TdlibParameters
and
core.telegram.org/tdlib/options
for details. You can obtain an :api_id
and an :api_hash
on
my.telegram.org : they are required by TDLib,
don’t forget to set them !
Be careful not to use the same :database_directory
for two different
sessions !
Open a new session. Spawns a new instance of tdlib-json-cli
.
session_name
is the identifier of the sessionclient_pid
is the PID of the process receiving the incoming messages ({:recv, struct}
)config
is the configuration of TDLib, seedefault_config/0
encryption_key
is the key used to encrypt the local database, it allows to store the session’s cache and authorization key even if the client is offline
Return either {:ok, pid}
or {:error, reason}
.
Transmit a message over the session identified by session_name
.
The parameter msg
must be a struct (any map in reality) since it is
directly encoded into JSON and transmitted via TDLib. You should use the
structures generated from TDLib’s documentation and provided by the
submodules of TDLib.Object
and TDLib.Methods
.
Alternatively it is also possible to directly provide an already encoded binary or string, althrough you should not need it.
Set the process receiving the incoming update for session
session_name
to client_pid
. The incoming messages can be handled with
def handle_info({:recv, msg}, state), do: ...
using GenServer.
The client is initially set when the session is create, using open/3
.