0

Tethering preparing a chat project.

Getting Server-Side Users

function TdmServer.OnlineUserSearch:  Boolean;
var
  I: Integer;
  ConnectedProfiles : String;
begin
  if TetheringManager1.RemoteProfiles.Count > 0 then
  begin
    for I := 0 to TetheringManager1.RemoteProfiles.Count - 1 do
    begin
       ConnectedProfiles := TetheringManager1.RemoteProfiles.Items[I].ProfileText;
       AddOnlineUserList(I,ConnectedProfiles);
    end;
  end
end;
procedure TdmServer.AddOnlineUser(pUserId: Integer; pUserName: String);
begin
  try
    if not IsThereAuserSearch(pUserId)  then //Are there any users? 
    begin
      queryOnlineUser.Open;
      queryOnlineUser.Insert;
      queryOnlineUser.FieldByName('UserId').AsInteger :=  pUserId ;
      queryOnlineUser.FieldByName('UserName').AsString := pUserName;
      queryOnlineUser.Post;
      queryOnlineUser.Refresh;
    End;
  Except
  end;
end;

Client

The user added to the server side specifies the customer side, and I assigned them to a list author. What should I do if user one wants to talk to an online user?

according to this

procedure TClientMain.btnSendClick(Sender: TObject);
var
  I : Integer;
begin
  begin

    case lvMessagetype of

     // by user group

      eGroup:
      begin
  //       if  then

      end;

       // Conversation with Single User
      eUser:
      begin

      end;

       // sending messages to all users

      eAllUser:
      begin
        For I := 0 to ClientAppProfile.ConnectedProfiles.Count -1 do
        begin
          TThread.Synchronize(nil,procedure begin ClientAppProfile.SendString(ClientAppProfile.ConnectedProfiles[I],memSendmessage.Text,memSendmessage.Text) end);
        end;
      end;
    end;
    memSendmessage.Clear;
  end;
end;

I want to send a message to a user from the list

*Case *

eGroup specified in case: users selected for the same group in the database

For example: When sending a group of books to a group, there are 3 users. send a message to these 3 users

How should I do the customer side I want.

I'm waiting for your help.

Thank you

  • For a chat application I'd suggest some efficient transport channel (which is not [yet] part of Delphi). I mean, I would do such application in another programming language. – TLama Nov 29 '19 at 12:46
  • I brought the project here, only the user will send a message to another user by the customer I want to do this – software specialist Nov 29 '19 at 17:09

0 Answers0