MsgCommunicator: Delphi Instant Messaging (IM) SDK
for easy creation of custom messenger system
Sends a file with progress indicator support.
function SendFile(ToUserID: Cardinal;
const FileName: String;
Blocks: Integer = 0;
BlockSize: Integer = 0;
Directly: Boolean = True): Integer;
Call SendFile to send a file. SendFile sends request to the recepient. If receiving side has AllowFiles property set to True, recepient enable sender to send, in other case one of the error codes (starting with MSG_Error_InitProgressSend) occurs. After this initial procedure, client sends file splitted by blocks as usual messages. Client can send/receive any number of files at the same time.
ToUserID is an unique idetifier of a recepient, client or server.
FileName - name of the file on the machine's file system.
Blocks - number of blocks the file will be split in transmission.
BlockSize - maximum size (in bytes) of one block (latest block can be less).
Directly - set to False to send thru server. If a client cannot send file directly, it will try to send it thru server automatically.
Set BlockSize to specify the size of portions the file will be sent by. BlockSize is the size of file data which will be transmetted for a single portion. The size of network packet can be greater due packet header will be added. If you specify too small size, it will be set to default value MsgDefaultPacketSize (including packet header) for maximal compliance with network MTU. If BlockSize you specified is greater then the PacketSize property, each data portion will be sent as a number of network packets.
Set Blocks to specify the number of portion the file will be split into. In this case BlockSize will be defined based on file size and specified Blocks parameter.
To learn the progress state, set event handler TMsgClient.OnSendFile.
To receive files on the other side, set event handler OnReceiveFile.
If SendFile is finished successfully, it returns MSG_COMMAND_OK.
SendFile can return one of the following error codes: