Exemplo n.º 1
0
        void MainForm_Load(object sender, EventArgs e)
        {
            log.InfoFormat("Manager is starting...");
            var name   = GetType().Name;
            var client = new RabbitBroker();

            client.Open();
            Client = client;
            log.InfoFormat("Manager is started!");
            var id = client.Id;

            client.Subscribe <HelloMessage>(id.Broad, OnResponse);
            foreach (var pair in AddinExtensions.GetFiltered <ResponseDescAttribute, IResponse>())
            {
                var resp     = pair.Value;
                var rType    = resp.GetType();
                var subName  = nameof(client.Subscribe);
                var subMeth  = client.GetType().GenericMe(subName, rType);
                var hndlMeth = GetType().GenericMe(nameof(OnResponse), rType);
                var act      = typeof(Action <,>).MakeGenericType(typeof(IIdentity), rType);
                var dlgt     = Delegate.CreateDelegate(act, this, hndlMeth);
                Invoke(client, subMeth, id.Uni, dlgt, rType);
                Invoke(client, subMeth, id.Multi, dlgt, rType);
            }
        }
Exemplo n.º 2
0
        static void ServerLoop(object state)
        {
            var addr   = (ITransfer)state;
            var server = new RabbitBroker();

            server.Open();
            Thread.Sleep(2 * 1000);
            server.Subscribe <string>(addr, (s, m) => Console.WriteLine($"{s.Uni} => {m}"));
        }