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

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.

Bileşen sınıfı

TsgcHTMLComponent_Chat

İşler

Kapsamlı CSS + mesajlaşma işaretlemesi

Diller

Delphi, C++ Builder, .NET

Oluşturun, iletiler ekleyin, işleyin

Ü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

Temel özellikler & yöntemler

En sık başvurduğunuz üyeler.

İletiler

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.

İleti ekleme

AddMessage, AddImageMessage, AddFileMessage ve AddSystemMessage(...) balonlar ekler; maLeft/maRight tarafı seçer.

Üstbilgi

Title, Subtitle, HeaderAvatarURL ve HeaderAvatarInitials konuşma üstbilgisini oluşturur (bir "online" alt başlığı yeşil noktayı ekler).

Oluşturma çubuğu

ShowInput, InputPlaceholder, ShowAttachButton, ShowEmojiButton, ShowTypingIndicator ve TypingText, alt çubuğu ayarlar.

Seçenekler

Options (bir TsgcHTMLChat_Options), MaxBubbleWidth, balon/arka plan renkleri, ShowTimestamp, ShowStatus, GroupConsecutive ve ShowDateSeparators'ı ayarlar.

Olaylar & çıktı

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.

Keşfetmeye devam edin

Tüm sgcHTML Bileşenleri60'tan fazla bileşenin tam özellik matrisine göz atın.
Ücretsiz Deneme Sürümünü İndirin30 günlük deneme, 60.HTML demo projeleriyle birlikte gelir.
FiyatlandırmaTam kaynak kodlu Single, Team ve Site lisansları.

Başlamaya Hazır mısınız?

Ücretsiz deneme sürümünü indirin ve Delphi, C++ Builder ve .NET'te web arayüzleri oluşturmaya başlayın.