示例#1
0
        static void Main(string[] args)
        {
            SharedXmlConfigReader cr = new SharedXmlConfigReader();
            var cfg = cr.Load( File.OpenText("../../../../data/SharedConfig.xml") );

            var cl = new Client("cl1", "localhost", 12345);
            cl.Connect();

            LaunchPlan plan1 = new LaunchPlan(
                "plan1",
                new List<AppDef>()
                {
                    new AppDef() { AppIdTuple = new AppIdTuple("m1", "a"), StartupOrder = -1, Dependencies=new List<string>() {"b"} },
                    new AppDef() { AppIdTuple = new AppIdTuple("m1", "b"), StartupOrder = -1, },
                    new AppDef() { AppIdTuple = new AppIdTuple("m1", "c"), StartupOrder = -1, Dependencies=new List<string>() {"b"} },
                    new AppDef() { AppIdTuple = new AppIdTuple("m1", "d"), StartupOrder = -1, Dependencies=new List<string>() {"a"} },
                }
            );

            cl.BroadcastMessage( new LoadPlanMessage(plan1) );

            var messages = cl.ReadMessages();
            foreach( var msg in messages )
            {
                Console.WriteLine("Received: {0}", msg.ToString());

                if( msg.GetType() == typeof(LoadPlanMessage) )
                {
                    LoadPlanMessage m = msg as LoadPlanMessage;
                    Console.WriteLine("  LoadPlan '{0}' ({1} applications)", m.plan.Name, m.plan.getAppDefs().Count<AppDef>());
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Client client = null;

            try
            {
#if USE_APP_CONFIG
                client = new Client();
#else
                ServerConfiguration cfg = new ServerConfiguration();
                cfg.Host = "localhost";
                cfg.TlsConfiguration.Enabled = false;

                Dictionary <ushort, ProtocolConfiguration> protocolConfigurations =
                    new Dictionary <ushort, ProtocolConfiguration>();

                protocolConfigurations.Add(KeepAliveProtocol.PROTOCOL_IDENTIFIER,
                                           new ProtocolConfiguration(KeepAliveProtocol.PROTOCOL_IDENTIFIER, typeof(KeepAliveProtocol)));

                protocolConfigurations.Add(WinAuthProtocol.PROTOCOL_IDENTIFIER,
                                           new ProtocolConfiguration(WinAuthProtocol.PROTOCOL_IDENTIFIER, typeof(WinAuthProtocolClient)));

                protocolConfigurations.Add(HelloProtocol.PROTOCOL_IDENTIFIER,
                                           new ProtocolConfiguration(HelloProtocol.PROTOCOL_IDENTIFIER, typeof(HelloProtocolClient)));


                client = new Client(cfg, protocolConfigurations);
                //client.Logger.LogPackets = true;
                client.Logger.LogToDebuggerOutputView = true;
                client.Logger.LogDebug = true;
#endif

                client.Connect();

                ushort[] serverSupportedProtocolIds = client.GetServerSupportedProtocolIds();
                Console.WriteLine(string.Format(
                                      "Server Supported Protocol IDs: {0}",
                                      string.Join(", ", serverSupportedProtocolIds)));

                string userName           = "******";
                WinAuthProtocolClient wap = client.Initialize(WinAuthProtocol.PROTOCOL_IDENTIFIER) as WinAuthProtocolClient;
                wap.Authenticate(userName, "T3stus3r", null);
                if (!wap.IsAuthenticated)
                {
                    throw new Exception("Access denied.");
                }

                client.Initialize(KeepAliveProtocol.PROTOCOL_IDENTIFIER);

                HelloProtocolClient hpc = (HelloProtocolClient)client.Initialize(HelloProtocol.PROTOCOL_IDENTIFIER);
                string serverReponse    = hpc.Hello(userName);
                Console.WriteLine(serverReponse);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.ReadKey();
                if (client != null)
                {
                    client.Close();
                }
            }
        }