Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using TS3QueryLib.Core;
- using TS3QueryLib.Core.Client;
- namespace tsbot
- {
- class App
- {
- private AsyncTcpDispatcher AsyncQueryDispatcher;
- private TS3QueryLib.Core.Server.QueryRunner AsyncServerQueryRunner;
- static void Main(string[] args)
- {
- new App().Start();
- }
- private void Connect()
- {
- try
- {
- Log("Creating ASync");
- AsyncQueryDispatcher = new AsyncTcpDispatcher("remote.ip", 13337);
- AsyncQueryDispatcher.ReadyForSendingCommands += QueryDispatcher_ReadyForSendingCommands;
- AsyncQueryDispatcher.Connect();
- Log("ASync connected");
- }
- catch (Exception ex)
- {
- Log("Cannot connect", "fatal", ex.Message);
- }
- }
- private void QueryDispatcher_ReadyForSendingCommands(object sender, System.EventArgs e)
- {
- Log("Ready for sending");
- AsyncServerQueryRunner = new TS3QueryLib.Core.Server.QueryRunner(AsyncQueryDispatcher);
- AsyncServerQueryRunner.RegisterForNotifications(TS3QueryLib.Core.Server.Entities.ServerNotifyRegisterEvent.Server | TS3QueryLib.Core.Server.Entities.ServerNotifyRegisterEvent.Channel);
- Log("Logging in async");
- AsyncServerQueryRunner.Login("srv", "pass");
- AsyncServerQueryRunner.SelectVirtualServerById(1);
- Log("Async logged in");
- }
- public void Start()
- {
- Connect();
- while (true) ;
- }
- public static void Log(String msg, String type = null, String reason = null)
- {
- if(type != null)
- {
- Console.Write("[" + type.ToUpper() + "] ");
- }
- if(reason != null)
- {
- Console.WriteLine(msg + " Reason: " + reason);
- }
- else
- {
- Console.WriteLine(msg);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement