Example #1
0
        public Form1()
        {
            InitializeComponent();
            Server = new TcpServer();
            Server.ServerStarted        += Server_StateChanged;
            Server.ServerStopped        += Server_StateChanged;
            Server.ClientConnected      += Server_ClientConnected;
            Server.ClientDisconnected   += Server_ClientDisconnected;
            propertyGrid1.SelectedObject = Server;

            AppServer = new TcpAppServer(this);
            AppServer.WelcomeMessage      = "Welcome to TCP Application Server. Copyright (C) Code Art Engineering.";
            AppServer.ClientConnected    += AppServer_ClientConnected;
            AppServer.ClientDisconnected += AppServer_ClientDisconnected;


            //TCP Application Server Customization Test
            AppServer.RegisterCommand("CustomFunction", "Dummy Custom Function", customFunctionCallback);
            AppServer.RegisterCommand("CustomFunction2", "Dummy Custom Function with Parameter", customFunction2Callback,
                                      new TcpAppParameter("P1", "Parameter 1"),
                                      new TcpAppParameter("P2", "Parameter 2, optional.", "10"));

            CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin SamplePlugin = new CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin();
            AppServer.RegisterPluginType("SamplePlugin", typeof(CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin));

            propertyGrid2.SelectedObject = AppServer;
        }
Example #2
0
        public Form1()
        {
            InitializeComponent();
            Server                       = new TcpServer();
            Server.MaxClients            = 5;
            Server.ServerStarted        += Server_StateChanged;
            Server.ServerStopped        += Server_StateChanged;
            Server.ClientConnected      += Server_ClientConnected;
            Server.ClientDisconnected   += Server_ClientDisconnected;
            propertyGrid1.SelectedObject = Server;

            AppServer = new TcpAppServer()
            {
                WelcomeMessage = "Welcome to TCP Application Server. Copyright (C) Code Art Engineering."
            };
            AppServer.MaxClients          = 5;
            AppServer.ExecutionTimeout    = 1000;
            AppServer.ClientConnected    += AppServer_ClientConnected;
            AppServer.ClientDisconnected += AppServer_ClientDisconnected;
            AppServer.ClientSignedIn     += AppServer_ClientInitialized;
            AppServer.ClientSigningOut   += AppServer_ClientSigningOut;
            tcpClientsList1.AssignObject(AppServer);
            tcpAppServerQueue1.AssignObject(AppServer);

            //TCP Application Server Customization Test
            AppServer.RegisterCommand("CustomFunction", "Dummy Custom Function", customFunctionCallback);
            AppServer.RegisterCommand("CustomFunction2", "Dummy Custom Function with Parameter", customFunction2Callback,
                                      TcpAppParameter.CreateParameter("P1", "Parameter 1"),
                                      TcpAppParameter.CreateOptionalParameter("P2", "Parameter 2, optional.", "10"));
            AppServer.RegisterCommand("SlowCommand", "Command which take 10 seconds to complete. Simulate blocking!", SlowCommand);
            AppServer.RegisterQueuedCommand("SlowCommandQ", "Command which take 10 seconds to complete. Run in queue. Simulate blocking!", SlowCommand);

            CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin SamplePlugin = new CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin();
            AppServer.RegisterPluginType(typeof(CodeArtEng.Tcp.Tests.TcpAppServerSamplePlugin));
            AppServer.RegisterPluginType(typeof(CodeArtEng.Tcp.Tests.TcpAppServerSimpleMath));

            propertyGrid2.SelectedObject = AppServer;
        }