Example #1
0
        protected static void Connection_Connected(FrostbiteConnection sender)
        {
            Console.WriteLine("Connected");

            // Now attempt a login.
            sender.Login();
        }
Example #2
0
 protected static void Connection_Disconnected(FrostbiteConnection sender)
 {
     Console.WriteLine("Disconnected");
 }
Example #3
0
 protected static void Connection_Error(FrostbiteConnection sender, Exception e)
 {
     Console.WriteLine("ERROR: {0}", e.Message);
 }
Example #4
0
        static void Main()
        {
            Program.Connection = new FrostbiteConnection();

            // You should populate and uncomment the below details to avoid having to enter them each run.
            // Program.Connection.Hostname = "";
            // Program.Connection.Port = 27000;
            // Program.Connection.PlainTextPassword = "";

            Program.Connection.PacketReceived += new FrostbiteConnection.PacketHandler(Connection_PacketReceived);
            Program.Connection.PacketSent     += new FrostbiteConnection.PacketHandler(Connection_PacketSent);
            Program.Connection.Connected      += new FrostbiteConnection.EmptyParameterHandler(Connection_Connected);
            Program.Connection.Disconnected   += new FrostbiteConnection.EmptyParameterHandler(Connection_Disconnected);
            Program.Connection.Error          += new FrostbiteConnection.ErrorHandler(Connection_Error);

            while (String.IsNullOrEmpty(Program.Connection.Hostname) == true)
            {
                Console.Write("Hostname: ");
                Program.Connection.Hostname = Console.ReadLine();
            }

            while (Program.Connection.Port == 0)
            {
                string portInput = String.Empty;
                ushort port;

                do
                {
                    Console.Write("Port: ");
                    portInput = Console.ReadLine();
                } while (ushort.TryParse(portInput, out port) == false);

                Program.Connection.Port = port;
            }

            while (String.IsNullOrEmpty(Program.Connection.PlainTextPassword) == true)
            {
                Console.Write("Password: "******"Type 'exit' to close the application");
            Console.WriteLine("Try the following commands:");
            Console.WriteLine("\tadmin.help");
            Console.WriteLine("\tadmin.say \"Hello World!\" all");
            Console.WriteLine("\tadmin.eventsEnabled true");
            Console.WriteLine("Attempting connection to {0}:{1}", Program.Connection.Hostname, Program.Connection.Port);
            Program.Connection.Connect();

            while (Program.Connection.Client.Connected == true)
            {
                String messageInput = Console.ReadLine();

                if (String.Compare(messageInput, "exit", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Program.Connection.Shutdown();
                }
                else
                {
                    Program.Connection.Command(messageInput.Wordify());
                }
            }

            Console.Write("Press any key to continue..");
            Console.ReadLine();
        }
Example #5
0
 protected static void Connection_PacketReceived(FrostbiteConnection sender, Packet packet)
 {
     Console.WriteLine("RECV: {0}", packet);
 }
Example #6
0
 protected static void Connection_PacketSent(FrostbiteConnection sender, Packet packet)
 {
     Console.WriteLine("SENT: {0}", packet);
 }