This project has moved and is read-only. For the latest updates, please go here.

Use of QueryRunner.Notifications

Feb 9, 2012 at 4:10 PM
Edited Feb 9, 2012 at 4:27 PM

I'm having some problems getting Notifications to work. I can't find any reference to it being unfinished, but I found no examples either.n

I'm trying to get notified when a user joins my server. This is a slightly simplified code snippet:

queryRunner.Login(_userName, _password);
queryRunner.SelectVirtualServerById(1);

queryRunner.Notifications.ClientJoined += OnClientJoined;
queryRunner.Notifications.ClientMoved += OnClientMoved;
queryRunner.RegisterForNotifications(TS3QueryLib.Core.Query.HelperClasses.ServerNotifyRegisterEvent.Server);

var defaultChannel = queryRunner.GetChannelList().First();
queryRunner.RegisterForNotifications(TS3QueryLib.Core.Query.HelperClasses.ServerNotifyRegisterEvent.Channel, defaultChannel.ChannelId);

After this I block the thread, waiting for something to happen. Neither of the two event handling methods are being called.
Am I doing something wrong? I also tried without the optional channel ID.

Feb 10, 2012 at 4:37 PM

You must use the AsyncTcpDispatcher (not SyncTcpDispatcher)
The synchronous tcp dispatcher does not support notifications.

 

When using the AsyncTcpDispatcher be aware, that there is an event "ReadyForSendingCommands" on the AsyncTcpDispatcher class. You need to attach to this event and only start fireing events against the query-runner when this event was first called.

May 12, 2014 at 11:29 AM
Edited May 12, 2014 at 11:41 AM
Hi,
I ve got same problems using the asynctcpdispatcher. How do it work?
        Try
            AsyncDispatcher = New AsyncTcpDispatcher(server, port)
            AsyncDispatcher.Connect()
            AddHandler AsyncDispatcher.ReadyForSendingCommands, AddressOf readyForSendingCommands
        Catch ex As Exception

        End Try
    Private Sub readyForSendingCommands(sender As Object, e As EventArgs)
        tsQuery = New TS3QueryLib.Core.Server.QueryRunner(AsyncDispatcher)

    End Sub
Can you give me a simple example for getting a connection and listen for notification (messages or s.th)

Thanks
May 19, 2014 at 10:16 AM
got it