Chat
TsgcHTMLComponent_Chat — komunikator w stylu WhatsApp z wiadomościami tekstowymi, obrazami, plikami, audio i wideo, potwierdzeniami odczytu, odpowiedziami i separatorami dat, w Delphi, C++ Builder i .NET.
TsgcHTMLComponent_Chat — komunikator w stylu WhatsApp z wiadomościami tekstowymi, obrazami, plikami, audio i wideo, potwierdzeniami odczytu, odpowiedziami i separatorami dat, w Delphi, C++ Builder i .NET.
Pełna powierzchnia czatu, która generuje dedykowany CSS wraz ze znacznikami komunikatora: nagłówek z awatarem, grupowane dymki, znaczniki statusu, załączniki multimedialne i pole tworzenia wiadomości. Dodaj wiadomości, ustaw nagłówek, a następnie odczytaj właściwość HTML.
TsgcHTMLComponent_Chat
Dedykowany CSS + znaczniki komunikatora
Delphi, C++ Builder, .NET
Ustaw nagłówek (Title, Subtitle, HeaderAvatarInitials), dodaj wiadomości tekstowe, obrazy i pliki, obsłuż OnSendMessage, a następnie odczytaj HTML.
uses
sgcHTML_Enums, sgcHTML_Component_Chat;
var
oChat: TsgcHTMLComponent_Chat;
begin
oChat := TsgcHTMLComponent_Chat.Create(nil);
try
oChat.Title := 'Alice Johnson';
oChat.Subtitle := 'online';
oChat.HeaderAvatarInitials := 'AJ';
oChat.Height := '500px';
oChat.ShowTypingIndicator := True;
oChat.OnSendMessage := DoSendMessage; // browser -> your code
oChat.AddSystemMessage('Today');
oChat.AddMessage('Alice', 'Hey! Did you get the file?', maLeft);
oChat.AddImageMessage('You', '/img/receipt.png', maRight,
hcPrimary, 'Here it is');
oChat.AddFileMessage('You', '/files/report.pdf',
'report.pdf', '248 KB', maRight);
WebModule.Response := oChat.HTML; // messenger markup + scoped CSS
finally
oChat.Free;
end;
end;
// OnSendMessage fires when the visitor submits the composer:
procedure TForm1.DoSendMessage(Sender: TObject; const aMessage: string);
begin
oChat.AddMessage('You', aMessage, maRight, hcPrimary);
WebSocket.WriteData(oChat.GetLastMessageHTML);
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Chat.hpp
TsgcHTMLComponent_Chat *oChat = new TsgcHTMLComponent_Chat(NULL);
try
{
oChat->Title = "Alice Johnson";
oChat->Subtitle = "online";
oChat->HeaderAvatarInitials = "AJ";
oChat->Height = "500px";
oChat->ShowTypingIndicator = true;
oChat->OnSendMessage = DoSendMessage; // browser -> your code
oChat->AddSystemMessage("Today");
oChat->AddMessage("Alice", "Hey! Did you get the file?", maLeft);
oChat->AddImageMessage("You", "/img/receipt.png", maRight,
hcPrimary, "Here it is");
oChat->AddFileMessage("You", "/files/report.pdf",
"report.pdf", "248 KB", maRight);
String html = oChat->HTML; // messenger markup + scoped CSS
}
__finally
{
delete oChat;
}
using esegece.sgcWebSockets;
var chat = new TsgcHTMLComponent_Chat();
chat.Title = "Alice Johnson";
chat.Subtitle = "online";
chat.HeaderAvatarInitials = "AJ";
chat.Height = "500px";
chat.ShowTypingIndicator = true;
chat.OnSendMessage += (sender, message) => // browser -> your code
{
chat.AddMessage("You", message, TsgcHTMLChatMessageAlign.maRight, TsgcHTMLColor.hcPrimary);
};
chat.AddSystemMessage("Today");
chat.AddMessage("Alice", "Hey! Did you get the file?", TsgcHTMLChatMessageAlign.maLeft);
chat.AddImageMessage("You", "/img/receipt.png", TsgcHTMLChatMessageAlign.maRight,
TsgcHTMLColor.hcPrimary, "Here it is");
chat.AddFileMessage("You", "/files/report.pdf",
"report.pdf", "248 KB", TsgcHTMLChatMessageAlign.maRight);
string html = chat.HTML; // messenger markup + scoped CSS
Składniki, po które sięgasz najczęściej.
Messages to kolekcja TsgcHTMLChat_Messages; każda TsgcHTMLChat_Message niesie Text, MessageType (tekst/obraz/plik/audio/wideo/system), Status, ReplyToSender/ReplyToText i IsForwarded.
AddMessage, AddImageMessage, AddFileMessage i AddSystemMessage(...) dołączają dymki; maLeft/maRight wybierają stronę.
Title, Subtitle, HeaderAvatarURL i HeaderAvatarInitials tworzą nagłówek konwersacji (podtytuł "online" dodaje zieloną kropkę).
ShowInput, InputPlaceholder, ShowAttachButton, ShowEmojiButton, ShowTypingIndicator i TypingText dostrajają dolny pasek.
Options (TsgcHTMLChat_Options) ustawia MaxBubbleWidth, kolory dymka/tła, ShowTimestamp, ShowStatus, GroupConsecutive i ShowDateSeparators.
OnSendMessage wyzwala się, gdy odwiedzający wysyła wiadomość z pola tworzenia; OnMediaClick wyzwala się po dotknięciu multimediów. HTML zwraca czat; GetLastMessageHTML zwraca tylko najnowszy dymek do wypchnięć na żywo.