Safe Haskell | None |
---|---|
Language | Haskell2010 |
Bindings to TDLib Json interface
Synopsis
- data Client
- newClient :: IO Client
- destroyClient :: Client -> IO ()
- clientReceive :: Client -> Double -> IO (Maybe ByteString)
- clientSend :: Client -> ByteString -> IO ()
- clientExecute :: Client -> ByteString -> IO ()
- setLogFilePath :: ByteString -> IO Bool
- setLogMaxFileSize :: Int64 -> IO ()
- setLogVerbosityLevel :: Verbosity -> IO ()
- setLogFatalErrorCallback :: (ByteString -> IO ()) -> IO ()
Documentation
TDLib client, will be automacially destroyed as soon as there are no references pointing to it (backed by ForeignPtr
)
Creating, Destroying and Interacting with clients
Destroys the TDLib client instance. After this is called the client instance shouldn't be used anymore.
:: 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.
:: Client | The client. |
-> ByteString | JSON-serialized null-terminated request to TDLib. |
-> IO () |
Sends request to the TDLib client. May be called from any thread.
:: Client | The client. Currently ignored for all requests, so NULL can be passed. |
-> ByteString | JSON-serialized null-terminated request to TDLib. |
-> IO () |
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
:: 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.
:: 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.