function Receive(const Buffer: TBytes; Offset, Count: integer; out MessageType: TScWebSocketMessageType; out EndOfMessage: boolean): integer; overload;
function Receive(const Buffer: PByteArray; Count: integer; out MessageType: TScWebSocketMessageType; out EndOfMessage: boolean): integer; overload;
Description
Call Receive to read Count bytes from the received from the Web server data message into Buffer. Receive returns bytes count that was actually read.
If the client did not receive any messages from the server when calling the method, it will wait for the time specified in the Options.ReadWriteTimeout property. If no messages were received during this time, the method will return 0.
If at least one frame of the message was received, the method will return the data immediately, without waiting for the end of the message. If more than one message was received from the server, the method will return the data from the first one received.
To receive the entire message, use the ReceiveMessage method.
Parameters:
• | Buffer - an array of bytes, where the body of the received message will be recorded into; |
• | Offset - zero-based byte offset in Buffer that points to the beginning of the data filling; |
• | Count - a maximum number of data that can be recorded to Buffer; |
• | MessageType - types of data message received from the server and returned by this parameter; |
• | EndOfMessage - returns a status whether the message was completely retrieved. If a message was not completely retrieved, the parameter is set to False. |
Note: This method cannot be called in case if the OnMessage event handler is set. In this case, an exception will be generated.
See also