Chat
TsgcHTMLComponent_Chat — um mensageiro estilo WhatsApp com mensagens de texto, imagem, arquivo, áudio e vídeo, confirmações de leitura, respostas e separadores de data, em Delphi, C++ Builder e .NET.
TsgcHTMLComponent_Chat — um mensageiro estilo WhatsApp com mensagens de texto, imagem, arquivo, áudio e vídeo, confirmações de leitura, respostas e separadores de data, em Delphi, C++ Builder e .NET.
Uma superfície de chat completa que emite CSS com escopo mais o markup do mensageiro: um cabeçalho com avatar, bolhas agrupadas, ticks de status, anexos de mídia e um compositor. Adicione mensagens, defina o cabeçalho e então leia a propriedade HTML.
TsgcHTMLComponent_Chat
CSS com escopo + markup do mensageiro
Delphi, C++ Builder, .NET
Defina o cabeçalho (Title, Subtitle, HeaderAvatarInitials), adicione mensagens de texto, imagem e arquivo, trate OnSendMessage e então leia 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
Os membros que você usa com mais frequência.
Messages é uma coleção TsgcHTMLChat_Messages; cada TsgcHTMLChat_Message carrega Text, MessageType (texto/imagem/arquivo/áudio/vídeo/sistema), Status, ReplyToSender/ReplyToText e IsForwarded.
AddMessage, AddImageMessage, AddFileMessage e AddSystemMessage(...) adicionam bolhas; maLeft/maRight escolhem o lado.
Title, Subtitle, HeaderAvatarURL e HeaderAvatarInitials constroem o cabeçalho da conversa (um subtítulo "online" adiciona o ponto verde).
ShowInput, InputPlaceholder, ShowAttachButton, ShowEmojiButton, ShowTypingIndicator e TypingText ajustam a barra inferior.
Options (uma TsgcHTMLChat_Options) define MaxBubbleWidth, cores de bolha/fundo, ShowTimestamp, ShowStatus, GroupConsecutive e ShowDateSeparators.
OnSendMessage dispara quando o visitante envia pelo compositor; OnMediaClick dispara ao tocar em uma mídia. HTML retorna o chat; GetLastMessageHTML retorna apenas a bolha mais recente para envios ao vivo.
| Todos os Componentes sgcHTMLExplore a matriz completa de recursos com mais de 60 componentes. | Abrir | |
| Baixar Versão de Avaliação GratuitaA avaliação de 30 dias inclui os projetos de demonstração 60.HTML. | Abrir | |
| PreçosLicenças Single, Team e Site com código-fonte completo. | Abrir |