Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Socket/server signal handling
Forum Updated to NodeBB v4.3 + New Features

Socket/server signal handling

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    schala
    wrote on 24 Jul 2014, 00:43 last edited by
    #1

    I've been trying to create a client/server software architecture and so far it works as expected. However, I've gotten to the point where I want to do something such as private message handling or file transfer handling. The server slot that handles new connections currently connects various signals from each socket instance that joins the server upon login (signals for such things as user joined, user logged off, etc) My question is how would I selectively emit a signal to only specific object instances that are connected as opposed to all of them? If someone sends a private message and there's multile connections, I obviously don't want the server sending everyone that message.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 24 Jul 2014, 00:57 last edited by
      #2

      How do you categorize them as private message ? How do you identify which are the private clients. You need to apply these two filtering criteria on your own to incoming data. I'm not sure about your internal stuff.

      What I can suggest you based is that try subclass QTcpServer and implement incomingConnection(...). This may help you.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • S Offline
        S Offline
        schala
        wrote on 24 Jul 2014, 01:02 last edited by
        #3

        Well, the format of the packets that are sent and received usually contain user ID of the recipient and what not. The thing is, would every connected socket need to parse that packet for a user ID match? Seems like an unnecessary use of signal handling, even if a thread pool is used. Or is that how it's meant to be?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          schala
          wrote on 24 Jul 2014, 01:28 last edited by
          #4

          Ah wait, I figured it out. QObject is the holy grail of problem solving

          1 Reply Last reply
          0
          • I Offline
            I Offline
            IamSumit
            wrote on 24 Jul 2014, 07:23 last edited by
            #5

            Hii.

            You need to maintain a list at server side using container like QSet for storing client socket ids for all clients.
            and maintain another list using QMap for socket id and client id.

            Hope it helps.

            Be Cute

            1 Reply Last reply
            0
            • S Offline
              S Offline
              schala
              wrote on 25 Jul 2014, 18:29 last edited by
              #6

              Yeah, I got it nailed. As I said, sender() was what I needed that I apparently overlooked.

              1 Reply Last reply
              0

              1/6

              24 Jul 2014, 00:43

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved