コード例 #1
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            IConfigurationRoot configuration = builder.Build();

            IMessenger messenger = GetMessenger(configuration["messenger"]);

            Console.WriteLine(messenger.GetMessage());
        }
コード例 #2
0
        private static void RefreshMessages()
        {
            try
            {
                var requiredType = typeof(IMessenger);
                var url          = $"tcp://localhost:{serverPort}/{serverName}";
                remoteObject = (IMessenger)Activator.GetObject(requiredType, url);

                threadRunning = true;
                lock (lockObj) remoteObject.ClearMessage(id);
                Console.WriteLine("[CardOrganizer] Starting client");
            }
            catch (Exception ex)
            {
                Console.WriteLine("[CardOrganizer] Server not found");
                Console.WriteLine(ex);
            }

            while (threadRunning)
            {
                try
                {
                    lock (lockObj)
                    {
                        var msg = remoteObject.GetMessage(id);
                        if (msg != null)
                        {
                            var message = MessagePackSerializer.Deserialize <MsgObject>(msg);
                            message.Print();
                            messageAction(message, subId);
                        }
                    }

                    Thread.Sleep(100);
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine("ERROR: Old bug in MessagePack-CSharp (Duplicate type name within an assembly, issue #127)\n" +
                                      "Must use a fixed Assembly-CSharp-firstpass.dll for this to work with scriptloader in KK\n" + ex);
                    threadRunning = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    threadRunning = false;
                }
            }

            Console.WriteLine("[CardOrganizer] Stopping client");
        }
コード例 #3
0
 public Message Get()
 {
     return(_messenger.GetMessage());
 }
コード例 #4
0
 public ActionResult <string> Get()
 {
     return(_messenger.GetMessage());
 }