ThreadSafeMode turn on still get callback

Post here your questions about the C++ API for SFS2X

Moderators: Lapo, Bax, MBagnati

ganquan
Posts: 38
Joined: 17 Apr 2013, 01:42

ThreadSafeMode turn on still get callback

Postby ganquan » 22 Apr 2013, 11:13

Code: Select all

gSmartFox = new Sfs2X::SmartFox(true);
   gSmartFox->ThreadSafeMode(true);

// Add event listeners
   pConnectionTest = new ConnectionTest(gSmartFox);
   gSmartFox->AddEventListener(SFSEvent::CONNECTION, new EventListenerDelegate(ConnectionTest::OnSmartFoxConnection, (void*)pConnectionTest));
   gSmartFox->AddEventListener(SFSEvent::CONNECTION_LOST, new EventListenerDelegate(ConnectionTest::OnSmartFoxConnectionLost, (void*)pConnectionTest));
   gSmartFox->AddEventListener(SFSEvent::LOGIN, new EventListenerDelegate(ConnectionTest::OnSmartFoxLogin, (void*)pConnectionTest));
   ......

   while (GetMessage(&msg, NULL, 0, 0))
   {
      gSmartFox->ProcessEvents();

      if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
      {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
   }


turn ThreadSafeMode on and call gSmartFox->ProcessEvents(), i get OnSmartFoxConnection when connect, and OnSmartFoxLogin after send login request.

if i don't call gSmartFox->ProcessEvents():

Code: Select all

while (GetMessage(&msg, NULL, 0, 0))
   {
      //gSmartFox->ProcessEvents();

      if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
      {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
   }

i don't get OnSmartFoxConnection at first, but after send login request, i can still get OnSmartFoxLogin callback.
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: ThreadSafeMode turn on still get callback

Postby MBagnati » 23 Apr 2013, 08:33

We have a fix for this problem.
If error is critical for you, we can provide a patch to last released version 0.9.4. In this case, please contact us at info--at--smartfoxserver.com to give us an email address where send the update.
In any case, the fix will be released with next API version.

Return to “SFS2X C++ API”

Who is online

Users browsing this forum: No registered users and 33 guests