3 Replies Latest reply on Feb 11, 2007 2:03 AM by 807597

    Send Message Client to Client Via Server


      I am trying to create Messenger similar to msn but very simple.

      I have managed to create some parts of it after nonstop day night reading up on sockets, and threading etc.. so so far i have a Server + ServerThread and Client class, which is capable of:
      * Server that can accept multiple client connections.
      * Each client can send message to the server Only

      Thats all so far but I do intend to
      * Make Client send Client messages via the Server <-- Next Important Step
      * Add and Remove Users (User Lists)

      Lets say I have a Server (S) and Clients (C1) and (C2)
      at the moment both C1 and C2 can connect to S and send messages to it only.
      How can I, or what would I need to do so that I can make C1 and C2 actually send each other messages? I understand I may need the server to somehow get the messages recieved from C1 and C2 and send them to one another?

      Do correct me in my assumptions or methods I am using, as you may know better methods or techniques to use to implement what I need to do.



      P.S If you need anymore information in regards to this or have any questions, please do ask.
        • 1. Re: Send Message Client to Client Via Server
          Okay, seems like that may be hard then, okay how about

          Uniquely assigning some sought of ID to each thread that is created upon .accept?

          and a way to create a new channel between a thread to a thread?


          • 2. Re: Send Message Client to Client Via Server
            In the server you should implement a thread to serve incoming messagges. Messages received should be pushed in a queue shared by thread so must be synchronized. Another thread spools this queue and send messages into sockets connected with clients.
            Note that the client's serving threads is also your clients list.
            If you want to dispatch messages to some client without boadcasting to all you can push message in the queue adding information of clients to be dispatched (a single user or a group).
            • 3. Re: Send Message Client to Client Via Server
              thanks topfoxy for the reply, I've managed to send msgs to everyone and private... but used a different method i think.. basically on each connection it would add the sockets to a vector list adn the same with usernames. and to send to everyone on the server the thread will just loop all the socket vector sending it to each user.. on private it will use the uservector to get the index of the user name and then using that index to get hte socket and hten sending it to that socket only... :)... what do you think? good or bad?