public static int StartDoorMenu()
        {
            Console.WriteLine("* Starting wcDOOR32.Net CWildcatDoor Example #3**");
            Console.WriteLine("door.GetDeviceType(): {0}", door.GetDeviceType());
            Console.WriteLine("door.Node: {0}", door.Node);
            Console.WriteLine("door.UserName: {0}", door.UserName);
            Console.WriteLine("wcGlobal.From: {0}", wcGlobal.User.From);


            door.SetGlobalTimeout(0);  // turn off timeout
            door.PrepareCallBack();    // Allow for disconnect events to be captured.

            wcServerAPI.SetNodeActivity("wcDoor32.Net Example3!");
            door.ClearScreen();
            door.Writeln("@H@Welcome to WcDoor32.Net Example #3, @N@{0}", wcGlobal.User.Info.Name);
            door.Writeln("@H@BBS Name      : @N@{0}", wcGlobal.Makewild.BBSName);
            door.Writeln("@B@User          : @A@{0}", door.UserName);
            door.Writeln("@B@Login Node    : @A@{0}", door.LoginNode);
            door.Writeln("@B@Door Node     : @A@{0}", door.Node);
            door.Writeln("@[email protected] : @A@{0}", wcGlobal.Node);
            door.Writeln("@B@GetNode()     : @A@{0}", wcServerAPI.GetNode());
            door.Writeln("@B@Speed         : @A@{0}", door.Speed);
            door.Writeln("@B@ColorEnabled  : @A@{0}", door.ColorEnabled);
            door.Writeln();

            wcServerAPI.TWildcatServerGuid wg = new wcServerAPI.TWildcatServerGuid();
            wcServerAPI.WcGetWildcatServerGuid(ref wg);
            door.Writeln("@B@GUID          : @A@{0}", wg.szGuid);
            door.Writeln();


            door.Writeln("@H@** Do you wish to continue, [Y], N?@A@");
            if (!ReadYesNo())
            {
                return(0);
            }


            door.Writeln("@H@** MENU OPTIONS?@A@");
            door.Writeln("@B@(1) Option 1@A@");
            door.Writeln("@B@(2) Option 2@A@");
            door.Writeln("@B@(3) Option 3@A@");
            door.Writeln("@B@(4) Option 4@A@");

            while (true)
            {
                door.Write("@H@Enter Option: ");
                while (!door.CharReady())
                {
                    door.DelayMS(15);
                }
                char ch = (char)door.ReadKey();
                if (ch >= '1' && ch <= '4')
                {
                    door.Write("{0}", ch); break;
                }
                door.Writeln();
            }

            #region Primitive Dumb Terminal

            door.Writeln();
            door.Writeln("@E@Press / to quit:@N@");

            //------------------------------------------------------------
            // Primitive Dumb Terminal
            //------------------------------------------------------------

            int Active      = 2;      // When 1 pending idle timeout, when 0 exit
            int idleTimeout = 60 * 1; // seconds

            while (Active != 0)
            {
                switch (door.Event(idleTimeout * 1000))
                {
                case wcDoor32API.WCDOOR_EVENT_KEYBOARD:
                    Active = 2;
                    byte[] data = new byte[4];
                    int    rd   = door.Read(ref data, data.Length);
                    if (rd == 0)
                    {
                        continue;
                    }

#if DEBUG
                    string mykey    = "";
                    string mykeystr = "";
                    for (int i = 0; i < rd; i++)
                    {
                        byte c = data[i];
                        Console.WriteLine(
                            "{0} ch:| '{1}' {2,3} (0x{3:X}) | '{4}' {5,3} (0x{6:X} <- {7} | {8} | rd: {9}",
                            "-",
                            (c < 32) ? ' ' : (char)c, c, c,
                            (c < 32) ? ' ' : (char)c, c, c,
                            mykey,
                            mykeystr,
                            rd
                            );
                    }
#endif

                    // -------------------------------------
                    // Check first byte for escape/exit key
                    byte ch = data[0];
                    if (ch == '/')
                    {
                        Active = 0; break;
                    }
                    //if (ch == wcConsoleAPI.KEY_ESCAPE) { Active = 0; break; }
                    // -------------------------------------

                    // IBM Keyboard Scan Codes will come from a wcBASIC
                    // login to run the door.
                    if (ch == 0)
                    {
                        if (rd == 1)
                        {
                            ch = (byte)door.ReadKey();      // need to read extra key
                        }
                        else if (rd == 2)
                        {
                            ch = data[1];
                        }

                        switch (ch)
                        {
                        case (byte)'H': door.CursorUp(); break;

                        case (byte)'P': door.CursorDown(); break;

                        case (byte)'K': door.CursorLeft(); break;

                        case (byte)'M': door.CursorRight(); break;
                        }
                        continue;
                    }

                    if (!door.Write(data, rd))
                    {
                        Console.WriteLine("!!!!ERROR writing data!");
                    }
                    if (ch == wcConsoleAPI.KEY_CR)
                    {
                        data[0] = (byte)wcConsoleAPI.KEY_LF;
                        door.Write(data, 1);
                    }
                    break;

                case wcDoor32API.WCDOOR_EVENT_OFFLINE:
                    door.Write("\r\n** FORCE DISCONNECT **\r\n");
                    Active = 0;
                    break;

                case wcDoor32API.WCDOOR_EVENT_TIMEOUT:
                    Active--;
                    switch (Active)
                    {
                    case 0:
                        door.Write("\r\n** IDLE TIMEOUT - GOODBYE **\r\n");
                        break;

                    case 1:
                        door.Write("\r\n** IDLE TIMEOUT IN {0} SECONDS **\r\n", idleTimeout);
                        break;
                    }
                    break;

                case wcDoor32API.WCDOOR_EVENT_FAILED:
                    // ** WCDOOR_EVENT_FAILED
                    Active = 0;
                    break;
                }
            }
            #endregion

            door.Writeln("\r\n\r\nReturning to bbs...");
            door.Flush();
            return(0);
        }
        public static int StartDoor()
        {
            Console.WriteLine("* Starting wcDOOR32.Net CWildcatDoor Example #2**");

            CWildcatDoor door = new CWildcatDoor();

            Console.WriteLine("door.GetDeviceType(): {0}", door.GetDeviceType());
            Console.WriteLine("Node: {0}", door.Node);
            Console.WriteLine("UserName: {0}", door.UserName);
            Console.WriteLine("User.from: {0}", wcGlobal.User.From);

            door.SetGlobalTimeout(0);  // turn off timeout
            door.PrepareCallBack();    // Allow for disconnect events to be captured.

            wcServerAPI.SetNodeActivity("wcDoor32.Net Example2!");
            door.ClearScreen();
            door.Write(1, 1, "@H@Welcome to WcDoor32.Net Example #2, '{0}'.@N@", wcGlobal.User.Info.Name);
            door.CursorSave();
            door.Write(1, 3, "@B@User        : @A@{0}", door.UserName);
            door.Write(1, 4, "@B@Login Node  : @A@{0}", door.Node);
            door.Write(1, 5, "@B@Door Node   : @A@{0}", wcServerAPI.GetNode());
            door.Write(1, 7, "@E@Press / to quit:@N@");
            door.Writeln();
            door.CursorRestore();
            door.Writeln("expected to be at line 2 after CursorRestore()");

            #region Primitive Dumb Terminal

            //------------------------------------------------------------
            // Primitive Dumb Terminal
            //------------------------------------------------------------

            int Active      = 2;      // When 1 pending idle timeout, when 0 exit
            int idleTimeout = 60 * 1; // seconds

            while (Active != 0)
            {
                switch (door.Event(idleTimeout * 1000))
                {
                case wcDoor32API.WCDOOR_EVENT_KEYBOARD:
                    Active = 2;
                    byte[] data = new byte[4];
                    int    rd   = door.Read(ref data, data.Length);
                    if (rd == 0)
                    {
                        continue;
                    }

#if DEBUG
                    string mykey    = "";
                    string mykeystr = "";
                    for (int i = 0; i < rd; i++)
                    {
                        byte c = data[i];
                        Console.WriteLine(
                            "{0} ch:| '{1}' {2,3} (0x{3:X}) | '{4}' {5,3} (0x{6:X} <- {7} | {8} | rd: {9}",
                            "-",
                            (c < 32) ? ' ' : (char)c, c, c,
                            (c < 32) ? ' ' : (char)c, c, c,
                            mykey,
                            mykeystr,
                            rd
                            );
                    }
#endif

                    // -------------------------------------
                    // Check first byte for escape/exit key
                    byte ch = data[0];
                    if (ch == '/')
                    {
                        Active = 0; break;
                    }
                    //if (ch == wcConsoleAPI.KEY_ESCAPE) { Active = 0; break; }
                    // -------------------------------------

                    // IBM Keyboard Scan Codes will come from a wcBASIC
                    // login to run the door.
                    if (ch == 0)
                    {
                        if (rd == 1)
                        {
                            ch = (byte)door.ReadKey();      // need to read extra key
                        }
                        else if (rd == 2)
                        {
                            ch = data[1];
                        }

                        switch (ch)
                        {
                        case (byte)'H': door.CursorUp(); break;

                        case (byte)'P': door.CursorDown(); break;

                        case (byte)'K': door.CursorLeft(); break;

                        case (byte)'M': door.CursorRight(); break;
                        }
                        continue;
                    }

                    if (!door.Write(data, rd))
                    {
                        Console.WriteLine("!!!!ERROR writing data!");
                    }
                    if (ch == wcConsoleAPI.KEY_CR)
                    {
                        data[0] = (byte)wcConsoleAPI.KEY_LF;
                        door.Write(data, 1);
                    }
                    break;

                case wcDoor32API.WCDOOR_EVENT_OFFLINE:
                    door.Write("\r\n** FORCE DISCONNECT **\r\n");
                    Console.WriteLine("** WCDOOR_EVENT_OFFLINE - GOODBYE **");
                    Active = 0;
                    break;

                case wcDoor32API.WCDOOR_EVENT_TIMEOUT:
                    Active--;
                    switch (Active)
                    {
                    case 0:
                        door.Write("\r\n** IDLE TIMEOUT - GOODBYE **\r\n");
                        break;

                    case 1:
                        door.Write("\r\n** IDLE TIMEOUT IN {0} SECONDS **\r\n", idleTimeout);
                        break;
                    }
                    break;

                case wcDoor32API.WCDOOR_EVENT_FAILED:
                    Console.WriteLine("** WCDOOR_EVENT_FAILED - GOODBYE **");
                    Active = 0;
                    break;
                }
            }
            #endregion

            door.Writeln("\r\n\r\nReturning to bbs...");
            door.Flush();
            return(0);
        }
Beispiel #3
0
        public static int StartDoor()
        {
            Console.WriteLine("* Starting wcDOOR32.Net CWildcatDoor **");

            CWildcatDoor door = new CWildcatDoor();

            Console.WriteLine("door.GetDeviceType(): {0}", door.GetDeviceType());
            Console.WriteLine("Node: {0}", door.Node);
            Console.WriteLine("UserName: {0}", door.UserName);
            Console.WriteLine("User.from: {0}", wcGlobal.User.From);

            door.SetGlobalTimeout(0);  // turn off timeout
            door.PrepareCallBack();    // Allow for disconnect events to be captured.

            door.ClearScreen();
            door.DisplayFile("wc:\\bats\\wcdoor32-hello.bbs");

            wcServerAPI.SetNodeActivity("wcDoor32.Net Example1!");

            door.Writeln("@T@Welcome to WcDoor32.Net Example #1, {0}.@N@", wcGlobal.User.Info.Name);
            door.Writeln("@B@User        : @A@{0}", door.UserName);
            door.Writeln("@B@Login Node  : @A@{0}", door.Node);
            door.Writeln("@B@Door Node   : @A@{0}", wcServerAPI.GetNode());
            door.Writeln("@B@Speed       : @A@{0}", door.Speed);
            door.Writeln("@B@ColorEnabled: @A@{0}", door.ColorEnabled);
            door.Writeln("\r\n@E@Press ESCAPE or / to quit:@N@");

            //------------------------------------------------------------
            // Primitive Dump Terminal
            //------------------------------------------------------------

            int Active      = 2;      // When 1 pending idle timeout, when 0 exit
            int idleTimeout = 60 * 1; // seconds

            while (Active != 0)
            {
                switch (door.Event(idleTimeout * 1000))
                {
                case wcDoor32API.WCDOOR_EVENT_KEYBOARD:
                    Active = 2;
                    byte[] data = new byte[4];
                    int    rd   = door.Read(ref data, data.Length);
                    if (rd == 0)
                    {
                        continue;
                    }
                    // -------------------------------------
                    // Check first byte for escape/exit key
                    byte ch = data[0];
                    if (ch == '/')
                    {
                        Active = 0; break;
                    }
                    if (ch == wcConsoleAPI.KEY_ESCAPE)
                    {
                        Active = 0; break;
                    }
                    // -------------------------------------
                    if (!door.Write(data, rd))
                    {
                        Console.WriteLine("!!!!ERROR writing data!");
                    }
                    if (ch == wcConsoleAPI.KEY_CR)
                    {
                        data[0] = (byte)wcConsoleAPI.KEY_LF;
                        door.Write(data, 1);
                    }
                    break;

                case wcDoor32API.WCDOOR_EVENT_OFFLINE:
                    door.Write("\r\n** FORCE DISCONNECT **\r\n");
                    Console.WriteLine("** WCDOOR_EVENT_OFFLINE - GOODBYE **");
                    Active = 0;
                    break;

                case wcDoor32API.WCDOOR_EVENT_TIMEOUT:
                    Active--;
                    switch (Active)
                    {
                    case 0:
                        door.Write("\r\n** IDLE TIMEOUT - GOODBYE **\r\n");
                        break;

                    case 1:
                        door.Write("\r\n** IDLE TIMEOUT IN {0} SECONDS **\r\n", idleTimeout);
                        break;
                    }
                    break;

                case wcDoor32API.WCDOOR_EVENT_FAILED:
                    Console.WriteLine("** WCDOOR_EVENT_FAILED - GOODBYE **");
                    Active = 0;
                    break;
                }
            }

            door.Writeln("\r\n\r\nReturning to bbs...");

            // delay 500ms, 1/2 sec, alternative door.DelayMS(500)
            // then flush, to complete transmission, if any.
            door.Delay(0.5);
            door.Flush();

            // When finishing an app, not necessary to call
            // Shutdown() here.
            // CWildcDoor's destructor will shutdown automatically.
            door.ShutDown();
            return(0);
        }