Results 1 to 9 of 9

Thread: Client server based application issue (one server , multiple clients ) QT

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2015
    Location
    United States, Florida
    Posts
    6
    Qt products
    Qt4 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Post Client server based application issue (one server , multiple clients ) QT

    Hi guys,

    I have a client server Application, where multiple clients are connecting to the server . What I am doing is every time a client connects , a thread is created for that client and a sessionId is generated and stored in the Database.

    Now say for example, a client connects but somehow client is forcefully terminated (by task manager )
    Now I have a situation when trying to connect the same client - what I want is to use the same sessionID and thread and doesnot start a new thread , becuase session is already there in the database.

    Well , above mentioned funcitonality works well if there is no network (but client is running, and if network is back again, connection is established) but when client is terminated , and relogin attempt is made again, it should basically be doing the same thing repatriate the user with the old running session/Thread.

    But its not working at all.

    here is the code that is not working , basically invokeMethod is not working for the already created thread.
    Qt Code:
    1. QMetaObject::invokeMethod(entry.Connection(), "SetSocket", Qt::BlockingQueuedConnection, Q_ARG(SocketPointerStruct, socketPointerStruct));
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. qDebug()<<"User was logged in earlier, now in disconnected mode, a repatriation attempt will be made";
    2.  
    3. bool tempFlag = fSocket->disconnect();
    4. if(tempFlag)
    5. qDebug()<<"Disconnected all slots connected to fSocket";
    6. else
    7. qDebug()<<"failed to disconnected all slots connected to fSocket";
    8.  
    9. SocketPointerStruct socketPointerStruct;
    10. socketPointerStruct.fSocketPointer = fSocket;
    11. socketPointerStruct.fAutomaticLoginAttempt = automaticLoginAttempts;
    12. fSocket->moveToThread(entry.Connection()->thread());
    13. QMetaObject::invokeMethod(entry.Connection(), "SetSocket", Qt::BlockingQueuedConnection, Q_ARG(SocketPointerStruct, socketPointerStruct));
    14.  
    15. qDebug()<<"User is repatriated";
    16.  
    17. /* Set entry's connection's socket to this guys socket */
    18. fSocket = NULL;
    19. emit ended(this);
    To copy to clipboard, switch view to plain text mode 
    Problem is setSocket is never called in case client is force terminated, but if there is not network and client is still running then above code works well if network is back again.

    any pointers will be usefull.

    basically I have created a ConnectionThread class by subclassing QThread and trying the above code inside that.

    Thanks!
    Vishal
    Last edited by anda_skoa; 19th November 2015 at 08:33.

Similar Threads

  1. Replies: 3
    Last Post: 16th August 2015, 11:32
  2. Server with multiple clients without threads
    By kernel.roy in forum Qt Programming
    Replies: 7
    Last Post: 9th September 2010, 16:37
  3. Server with multiple clients without threads
    By kernel.roy in forum Newbie
    Replies: 2
    Last Post: 9th September 2010, 04:53
  4. Replies: 0
    Last Post: 31st July 2010, 17:27
  5. Replies: 7
    Last Post: 10th May 2010, 11:26

Tags for this Thread

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.