Debugger

This will tell you about Times Debugger and about using debugger

You can find the debug class in

This debugger is unique in it's way. It's similar to the event dispatcher class. It has no direct contact with Airtower or any of the server, but is a static class which dynamically handles the callbacks. You can add as many as debug callbacks and as many as callback handlers. All you neet to do is, know how it works and implement one then attach it to the server.

You'll see that in brief below.

The Debugger.cs have 3 methods, CallEvent, removeLogEvent, and addLogEvent respectively.
Method Arguments Description
CallEvent Event [String], args [Params] If there exist a callback for the Event, it will be executed. The parameters sent will be dynamic and is the same as args. Ie, args are sent as parameters/arguments.
addLogEvent Event [String], method [Delegate] If there exist a Event, it will add the delegate to it. If not present it will create and then add it to it.
removeLogEvent Event [String], method [Delegate] First it will check if Event exist. If it does, it will check if delegate is in the list, if it is in there, it will delete it from the list. Else returns.

Below is an example code, in console-based C# Project, to use/activate Airtower's Debugging event. You can further read about Event Delegate used in here in later topics.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Times
using Server.Utils.Events;
using Server.net;
using Server.Log;
using Client;

public class TestServer
{
   public static void Main()
   {
      // Initiate the Debugger class or activate the class
      inititate();
      Airtower loginServer = new Airtower("127.0.0.1", 6112); // You can auto-config here
      loginServer.IP = "new IP";
      loginServer.Name = "Times Test v2"; // You can access and edit it out-the class too!

      // Run the server
      loginServer.startConnection();
   }
   
  public static void inititate()
    {
       Times times = new Times();
       Debugger.addLogEvent(Connection.XT_EVENT, EventDelegate.create(times, "XTReceived"));
       Debugger.addLogEvent(Connection.XML_EVENT, EventDelegate.create(times, "XMLReceived"));
       Debugger.addLogEvent(Connection.WARN_EVENT, EventDelegate.create(times, "WARN"));
       Debugger.addLogEvent(Connection.INFO_EVENT, EventDelegate.create(times, "INFO"));
       Debugger.addLogEvent(Connection.ERROR_EVENT, EventDelegate.create(times, "ERROR"));

    }
}
// Here is where the Debugging event callbacks are handled.
class Times
{
    public Times()
    {

    }

    public void XTReceived(string packet)
    {
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("[RECEIVED XT] : " + packet);
        Console.ResetColor();
    }

    public void XMLReceived(string xmlPacket)
    {
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("[RECEIVED XML] : " + xmlPacket);
        Console.ResetColor();
    }

    public void WARN(string msg)
    {
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.WriteLine("[WARNING] : " + msg);
        Console.ResetColor();
    }

    public void INFO(string msg)
    {
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("[INFORMATION] : " + msg);
        Console.ResetColor();
    }

    public void ERROR(string msg)
    {
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("[ERROR] : " + msg);
        Console.ResetColor();
    }
}

Next move on to Event Dispatcher

check 1
Utilities
check 1
Debugger
check 3
Event Delegate
check 4
Packet handlers