tdlib-0.3.0: complete binding to the Telegram Database Library
Safe HaskellNone
LanguageHaskell2010

TDLib.TDJson

Description

Bindings to TDLib Json interface

Synopsis

Documentation

data Client Source #

TDLib client, will be automacially destroyed as soon as there are no references pointing to it (backed by ForeignPtr)

Instances

Instances details
Eq Client Source # 
Instance details

Defined in TDLib.TDJson

Methods

(==) :: Client -> Client -> Bool #

(/=) :: Client -> Client -> Bool #

Ord Client Source # 
Instance details

Defined in TDLib.TDJson

Show Client Source # 
Instance details

Defined in TDLib.TDJson

Creating, Destroying and Interacting with clients

newClient :: IO Client Source #

Creates a new instance of TDLib.

destroyClient Source #

Arguments

:: Client

The client.

-> IO () 

Destroys the TDLib client instance. After this is called the client instance shouldn't be used anymore.

clientReceive Source #

Arguments

:: Client

The client.

-> Double

The maximum number of seconds allowed for this function to wait for new data.

-> IO (Maybe ByteString)

JSON-serialized null-terminated incoming update or request response. May be NULL if the timeout expires.

Receives incoming updates and request responses from the TDLib client. May be called from any thread, but shouldn't be called simultaneously from two different threads. Returned pointer will be deallocated by TDLib during next call to clientReceive or clientExecute in the same thread, so it can't be used after that.

clientSend Source #

Arguments

:: Client

The client.

-> ByteString

JSON-serialized null-terminated request to TDLib.

-> IO () 

Sends request to the TDLib client. May be called from any thread.

clientExecute Source #

Arguments

:: Client

The client. Currently ignored for all requests, so NULL can be passed.

-> ByteString

JSON-serialized null-terminated request to TDLib.

-> IO (Maybe ByteString) 

Synchronously executes TDLib request. May be called from any thread. Only a few requests can be executed synchronously. Returned pointer will be deallocated by TDLib during next call to clientReceive or clientExecute in the same thread, so it can't be used after that.

Managing the internal logging of TDLib

setLogFilePath Source #

Arguments

:: ByteString

Null-terminated path to a file where the internal TDLib log will be written. Use an empty path to switch back to the default logging behaviour.

-> IO Bool

True on success, False otherwise.

Sets the path to the file where the internal TDLib log will be written. By default TDLib writes logs to stderr or an OS specific log. Use this method to write the log to a file instead.

setLogMaxFileSize Source #

Arguments

:: Int64

The maximum size of the file to where the internal TDLib log is written before the file will be auto-rotated. Should be positive.

-> IO () 

Sets the maximum size of the file to where the internal TDLib log is written before the file will be auto-rotated. Unused if log is not written to a file. Defaults to 10 MB.

setLogVerbosityLevel :: Verbosity -> IO () Source #

Sets the verbosity level of the internal logging of TDLib. By default the TDLib uses a log verbosity level of Verbose.

setLogFatalErrorCallback :: (ByteString -> IO ()) -> IO () Source #

Sets the callback that will be called when a fatal error happens. None of the TDLib methods can be called from the callback. The TDLib will crash as soon as callback returns. By default the callback is not set.