Results 1 to 4 of 4

Thread: Simple chat example. How can I make a list of participants?

  1. #1
    Join Date
    Jun 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Red face Simple chat example. How can I make a list of participants?

    Hi everyone!
    I need to make a chat. On your site I found an example. But there's no list of participants. How can I do?

    Do I understand that the data on a server need to send in that format?
    And if the server receives GRTNG, it verifies the existence of party with the same name and save it.?

    Qt Code:
    1. QByteArray arrBlock;
    2. QDataStream out (& arrBlock, QIODevice:: WriteOnly);
    3. out.setVersion (QDataStream:: Qt_4_5);
    4. out <<quint16 (0) << QString("GRTNG") << nick->text ();
    5. out.device () -> seek (0);
    6. out <<quint16 (arrBlock.size () - sizeof (quint16));
    7. socket-> write (arrBlock);
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. QByteArray arrBlock;
    2. QDataStream out (& arrBlock, QIODevice:: WriteOnly);
    3. out.setVersion (QDataStream:: Qt_4_5);
    4. out <<quint16 (0) << QString("MSG") << message->text ();
    5. out.device () -> seek (0);
    6. out <<quint16 (arrBlock.size () - sizeof (quint16));
    7. socket-> write (arrBlock);
    To copy to clipboard, switch view to plain text mode 

    I am sorry for my bad English. I hope you understand me.
    Last edited by Luga; 5th June 2009 at 17:48.

  2. #2
    Join Date
    May 2009
    Location
    Germany
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Simple chat example. How can I make a list of participants?

    Have you seen this: Network Chat Example

  3. #3
    Join Date
    Jun 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Simple chat example. How can I make a list of participants?

    Quote Originally Posted by kei View Post
    Have you seen this: Network Chat Example
    Yes, I have seen this example. This is not a client-server chat. And I did not understand the code. All very confusing.

  4. #4
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Simple chat example. How can I make a list of participants?

    On the server you have:

    Qt Code:
    1. QList<QTcpSocket*> connections;
    To copy to clipboard, switch view to plain text mode 

    so pretty much you just need to make an array of usernames which is indexed by the socket ID's in the list.

    whenever the list changes because other users connected, you would need to make the server send the list to all of the clients because only the server is aware of all the client connections.

Similar Threads

  1. How to make a simple table and calculate col sums?
    By teele in forum Qt Programming
    Replies: 4
    Last Post: 19th January 2011, 22:34
  2. How to make a list of QGraphicsItems on the scene
    By Holy in forum Qt Programming
    Replies: 8
    Last Post: 10th June 2008, 13:43
  3. which class i should used to make chat application ??
    By kunalnandi in forum Qt Programming
    Replies: 3
    Last Post: 3rd May 2008, 09:33
  4. make QTableView work as a multi-column list view
    By wesley in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2008, 14:43
  5. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.