Forum

Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Join Date
    February 2017
    Posts
    45

    What happens on disconnect??

    Hi

    i have a little problem. When i disconnect (or deactivate the plugin) my whole TS Client crashes.
    So what happens exactly in which order (what callbackes are used) when i deactivate the plugin and when i disconnect.

    You can browse my code here at my git repository: https://git.rwth-aachen.de/carstenf/...ay/tree/master

  2. #2
    Join Date
    September 2012
    Posts
    6,078
    Didn't explicitly check but iirc:

    on disconnect you will receive an onClientMoveEvent and an onConnectStatusChangedEvent on the tab that disconnected.

    when you disable the plugin, ts3plugin_shutdown will be called.

    When you quit the client first you will disconnect on every tab that was connected (or in the process of connecting) (see above events) and then the ts3plugin_shutdown function will be called.


    As for your crash:
    You access invalid memory when you disconnect in https://git.rwth-aachen.de/carstenf/...oller.cpp#L226 because you trust the channelIDList pointer to be valid, which it isn't since the client couldn't do what you asked for. The call in Line 220 will error out and indicate as such through its return value.

    On Shutdown you crash because you attempt to delete invalid memory. From the Qt Documentation:
    QMap::erase(iterator pos)

    Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to the next item in the map.
    So inevitably you're going to delete invalid memory on the last item in the map.
    Last edited by Chris; February 27th, 2017 at 06:27 PM.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  3. #3
    Join Date
    February 2017
    Posts
    45
    Yeah that fixed my problem. Thank you

    just a few more questions:

    What are those good for?
    ts3plugin_onClientIDsEvent
    ts3plugin_onClientIDsFinishedEvent

  4. #4
    Join Date
    September 2012
    Posts
    6,078
    Those are called after you call the requestClientIDs function. The first one is called 0 - n times (where n is the number of slots on the server), once for each connected client with the unique identifier specified in the requestClientIDs call. After that is done the FinishedEvent is called, indicating to you that you've received all client ids on the server for the requested unique id.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  5. #5
    Join Date
    February 2017
    Posts
    45
    Hi,

    can i ask you to review my code once more?? It crashes when i have a active connection and i deactivate the plugin. Disconnect->deactivate works fine.

    I played a bit around with hotkeys, but i think they don't cause the problem. Pretty sure it's because of my ChannelListWidget:
    https://git.rwth-aachen.de/carstenf/...b71a43bae09dfa

  6. #6
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Quote Originally Posted by GT-Anakin View Post
    I played a bit around with hotkeys, but i think they don't cause the problem. Pretty sure it's because of my ChannelListWidget:
    https://git.rwth-aachen.de/carstenf/...b71a43bae09dfa
    Does not sound, that this causes your crash, but you didn't implement the freeMemory callback.

    If I'm right, the testplugin is a bit unclear on that matter. But the memory allocated in initHotkeys is created in the plugins memory segment and should be freed in ts3plugin_freeMemory. So imho the comment needs to be updated with initHotkeys (eg. /* Required to release the memory for parameter "data" allocated in ts3plugin_infoData, "menuItems" and "menuIcon" in ts3plugin_initMenus and "hotkeys" in ts3plugin_initHotkeys */).

  7. #7
    Join Date
    February 2017
    Posts
    45
    ähm i fixed the crash caused by the widget. But my Hotkey is an other problem (the hotkey is not shown in the settings).
    And actually it's the next thing i'm gonna fix. So you say i need to free the memory. I copied everything from the example code did i miss something??

    (just fixed the missing free(data). That was soo stupid from me to remove it)
    https://git.rwth-aachen.de/carstenf/...ter/plugin.cpp

    But hotkeys are still not shown in my settings

  8. #8
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    You are mixing ts3plugin_freeMemory (the callback) and TS3Functions.freeMemory (the function) (for example).

    The client and a plugin have separated memory segments. So if the client allocates some memory (for you), it is allocated in the clients segment and passed to you. This happens for example with getClientVariableAsString. The client creates a c-string and pass the pointer to you. Afterwards, the memory needs to be freed by the client. So you need to trigger that with TS3Functions.freeMemory.

    In ts3plugin_initHotkeys it is the exact opposite. Your plugin allocates memory in the plugins segment and passes it to the client, so that it can read from it and copy the data. Afterwards the client will call ts3plugin_freeMemory, so that your plugin can free the memory.

    The one who allocated the memory, needs to free it.


    Just did a quick look:
    Code:
    BEGIN_CREATE_HOTKEYS(3);
    should be
    Code:
    BEGIN_CREATE_HOTKEYS(1);
    ?

    Remeber to activate the advanced settings in the hotkey settings. Otherwise plugin hotkeys won't show up.

  9. #9
    Join Date
    February 2017
    Posts
    45
    OK, i didn't know there is a different who frees the memory (always use new and delete from cpp)

    I updated that and changed the 3 to 1. But there needs to be something else that is missing:

    Click image for larger version. 

Name:	YiImequ.jpg 
Views:	40 
Size:	169.9 KB 
ID:	15085

  10. #10
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    The function declaration is commented out in your header (https://git.rwth-aachen.de/carstenf/...r/plugin.h#L44).

  11. #11
    Join Date
    February 2017
    Posts
    45
    i checked that file if i removed something by comparing my line number with the one from the sdk -.-

    But it works just fine now.

    If you are not already tired of my code, here is an other thing.
    https://git.rwth-aachen.de/carstenf/...lugin.cpp#L105

    I use this to get the right controller (if there are more then one server connection) and usual i have a serverConnectionId at the callbacks. But the hotkeys don't know the server, so i wanna go through my serverconnections and look which one is not muted, since that should be only one, right?
    But for some reason it is never found. Something needs to be wrong

  12. #12
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    I think the clientvariable you need to check is CLIENT_INPUT_HARDWARE.

  13. #13
    Join Date
    September 2012
    Posts
    6,078
    I guess it depends on what you want to do when the hotkey is pressed.

    There is getCurrentServerConnectionHandlerID which just returns the tab that is currently selected by the User, which in most cases should be what you're after.
    If you want to know the tab the user is speaking on (which isn't necessarily the one active in the UI right now) then go with what Thomas said and check CLIENT_INPUT_HARDWARE instead. CLIENT_IS_MUTED is actually whether or not you right clicked the client and selected "Mute Client".
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  14. #14
    Join Date
    May 2016
    Location
    Idar-Oberstein
    Posts
    163
    I'd imagine sth. more like that (for active mic variant):
    if (!serverConnectionHandlerID)
    {
    OverlayController* ret = nullptr;
    unsigned int error;
    for (auto it = g_serverList.cbegin(); it != g_serverList.cend(); ++it)
    {
    int tmp;
    if ((error = ts3Functions.getClientSelfVariableAsInt(it.key(), CLIENT_INPUT_HARDWARE, &tmp)) != ERROR_ok)
    {
    //potentionally_express_utter_disbelief_of_what_just _happened(error);
    continue;
    }

    if (tmp)
    {
    ret = it.value();
    break;
    }
    }
    return ret;
    }
    * iterates via iterators, hence doesn't need to look for the value anymore
    * getClientSelfVariableAsInt doesn't care about a client id, getClientVariableAsX does
    * continues on != ERROR_ok, looks at tmp if ERROR_ok
    * breaks out of the loop when found
    * code untested

  15. #15
    Join Date
    February 2017
    Posts
    45
    Name:  Unbenannt.JPG
Views: 131
Size:  8.8 KB

    I want to get the server where you are actually talking. So the state of the yellow marked icon, since there is always only one server where this is activated. Not the microphone state next to it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. 24h disconnect
    By tuvok1981 in forum Windows
    Replies: 17
    Last Post: January 27th, 2013, 02:02 PM
  2. Disconnect
    By Samonq in forum Client Support
    Replies: 0
    Last Post: January 1st, 2011, 01:15 PM
  3. Always disconnect
    By thunderstorm99 in forum Windows
    Replies: 0
    Last Post: August 1st, 2010, 06:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •