Chat
TsgcHTMLComponent_Chat — Delphi, C++ Builder ve .NET'te metin, görüntü, dosya, ses ve video iletileri, okundu bilgileri, yanıtlar ve tarih ayraçları içeren WhatsApp tarzı bir mesajlaşma.
TsgcHTMLComponent_Chat — Delphi, C++ Builder ve .NET'te metin, görüntü, dosya, ses ve video iletileri, okundu bilgileri, yanıtlar ve tarih ayraçları içeren WhatsApp tarzı bir mesajlaşma.
Kapsamlı CSS ile mesajlaşma işaretlemesini üreten kapsamlı bir sohbet yüzeyi: avatarlı bir üstbilgi, gruplanmış balonlar, durum işaretleri, medya ekleri ve bir oluşturma çubuğu. İletiler ekleyin, üstbilgiyi ayarlayın, ardından HTML özelliğini okuyun.
TsgcHTMLComponent_Chat
Kapsamlı CSS + mesajlaşma işaretlemesi
Delphi, C++ Builder, .NET
Üstbilgiyi (Title, Subtitle, HeaderAvatarInitials) ayarlayın, metin, görüntü ve dosya iletileri ekleyin, OnSendMessage'ı işleyin, ardından HTML'i okuyun.
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
En sık başvurduğunuz üyeler.
Messages bir TsgcHTMLChat_Messages koleksiyonudur; her TsgcHTMLChat_Message, Text, MessageType (metin/görüntü/dosya/ses/video/sistem), Status, ReplyToSender/ReplyToText ve IsForwarded taşır.
AddMessage, AddImageMessage, AddFileMessage ve AddSystemMessage(...) balonlar ekler; maLeft/maRight tarafı seçer.
Title, Subtitle, HeaderAvatarURL ve HeaderAvatarInitials konuşma üstbilgisini oluşturur (bir "online" alt başlığı yeşil noktayı ekler).
ShowInput, InputPlaceholder, ShowAttachButton, ShowEmojiButton, ShowTypingIndicator ve TypingText, alt çubuğu ayarlar.
Options (bir TsgcHTMLChat_Options), MaxBubbleWidth, balon/arka plan renkleri, ShowTimestamp, ShowStatus, GroupConsecutive ve ShowDateSeparators'ı ayarlar.
Ziyaretçi oluşturma çubuğunu gönderdiğinde OnSendMessage tetiklenir; OnMediaClick, bir medyaya dokunulduğunda tetiklenir. HTML sohbeti döndürür; GetLastMessageHTML, canlı gönderimler için yalnızca en yeni balonu döndürür.