コード例 #1
0
        void Run(string[] args)
        {
            // Read command line + set config
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-s":
                    UseScreen = Int32.Parse(args[++i]) - 1;
                    break;
                }
            }

            // Init rest of configuration
            Configuration.Width  = Screen.AllScreens[UseScreen].Bounds.Width;
            Configuration.Height = Screen.AllScreens[UseScreen].Bounds.Height;

            //Init window resources
            PaneBase.LoadWindowResources();

            // Init OpenGL
            Window              = new GameWindow(Configuration.Width, Configuration.Height, new GraphicsMode(), "", GameWindowFlags.Fullscreen, DisplayDevice.GetDisplay((DisplayIndex)UseScreen));
            Window.RenderFrame += Render;
            Window.UpdateFrame += Tick;

            InitRenderer();

            // Init Panes
            Panes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes())
                    .Where(x => typeof(PaneBase).IsAssignableFrom(x) && !x.IsAbstract)
                    .Select <Type, PaneBase>(x => (PaneBase)Activator.CreateInstance(x))
                    .Where(x => x.BaseInit())                                        // BaseInit() == false means the pane isn't production-ready
                    .OrderBy(x => x.ZIndex)
                    .ToList();

            // Init event bus protocol(s)
            MQTTClient = new MqttClient("mqtt://MQTTHost");
            MQTTClient.Connect("frontWindowDisplay");
            MQTTClient.Subscribe(new string[] { "token/events/string/here" }, new byte[] { 0 });
            MQTTClient.MqttMsgPublishReceived += MQTT_MessageReceived;

            StompClient = new STOMPClient("stomp://StompHost");
            StompClient.Subscribe("Token Events");
            StompClient.MessageReceived += StompClient_MessageReceived;

            // Start operation
            Window.Run(60, 60);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            STOMPClient Client = new STOMPClient();

            NextTest("Frame Serialize, Deserialize, Serialize");

            StompSendFrame Frame = new StompSendFrame("MyDestination", "This is the packet body here");

            Frame.Receipt = "ReceiptIdHere";
            Frame.AdditionalHeaders.Add(new KeyValuePair <string, string>("my-header", "MyValue"));

            string Output = Client.GetSerializedPacket(Frame);

            Console.WriteLine(Output);

            StompFrame Rebuilt = Client.GetBuiltFrame(System.Text.Encoding.UTF8.GetBytes(Output));

            Console.WriteLine("");
            Console.WriteLine("------");
            Console.WriteLine("");

            Output = Client.GetSerializedPacket(Rebuilt);
            Console.WriteLine(Output);

            Console.WriteLine("");
            Console.WriteLine("------");

            NextTest("RingBuffer Data Length");

            StompRingBuffer <int> Buffer = new StompRingBuffer <int>(128);

            int[] Data = new int[64];
            for (int i = 0; i < Data.Length; i++)
            {
                Data[i] = i + 1;
            }

            Buffer.Write(Data);

            Console.WriteLine(string.Format("Available Write before read: {0}", Buffer.AvailableWrite));

            int[] Data2 = Buffer.Read(Buffer.AvailableRead);
            Console.WriteLine(string.Format("Available Write after read: {0}", Buffer.AvailableWrite));
            Console.WriteLine(string.Format("Lengths: {0} and {1}", Data.Length, Data2.Length));

            NextTest("Data Comparison");

            for (int i = 0; i < Math.Min(Data.Length, Data2.Length); i++)
            {
                Console.WriteLine(string.Format("{0} {1}", Data[i], Data2[i]));
            }

            NextTest("Seek Back 32");

            Console.WriteLine(string.Format("Seek Ptr is {0}", Buffer.Seek(-32)));
            Console.WriteLine(string.Format("Available is {0}", Buffer.AvailableRead));
            Data2 = Buffer.Read(Buffer.AvailableRead);
            Console.WriteLine(string.Format("Read out {0}", Data2.Length));
            Console.WriteLine(string.Format("Seek Ptr is {0}", Buffer.Seek(0)));

            NextTest("Old Data");


            foreach (int D in Data2)
            {
                Console.WriteLine(string.Format("{0} ", D));
            }

            NextTest("Write and Read");

            Buffer.Write(Data, 32);
            Buffer.Seek(-32);
            Data2 = Buffer.Read(Buffer.AvailableRead);
            Console.WriteLine(string.Format("Write 32; Read out {0}", Data2.Length));

            NextTest("Data");

            foreach (int D in Data2)
            {
                Console.WriteLine(string.Format("{0} ", D));
            }

            NextTest("Seek Forward");

            Console.WriteLine(string.Format("Available Read is {0}, should be 0", Buffer.AvailableRead));

            Console.WriteLine(string.Format("Write {0}", Data.Length));
            Buffer.Write(Data);

            Console.WriteLine(string.Format("Available Read is {0}", Buffer.AvailableRead));
            Buffer.Seek(10);
            Console.WriteLine(string.Format("Seek; Ptr is {0}", Buffer.Seek(0)));
            Console.WriteLine(string.Format("Available Read is {0}", Buffer.AvailableRead));

            Data2 = Buffer.Read(Buffer.AvailableRead);
            Console.WriteLine(string.Format("Read out {0}", Data2.Length, Data.Length));
            Console.WriteLine(string.Format("Available Read is {0}", Buffer.AvailableRead));

            Console.WriteLine(string.Format("Seek Ptr is {0}", Buffer.Seek(0)));

            NextTest("Data");

            foreach (int D in Data2)
            {
                Console.WriteLine(string.Format("{0} ", D));
            }

            Console.ReadLine();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Sukasa/StompClient
        static void Main(string[] args)
        {
            STOMPClient Client = new STOMPClient();

            NextTest("Frame Serialize, Deserialize, Serialize");

            StompSendFrame Frame = new StompSendFrame("MyDestination", "This is the packet body here");

            Frame.Receipt = "ReceiptIdHere";
            Frame.AdditionalHeaders.Add(new KeyValuePair<string, string>("my-header", "MyValue"));

            string Output = Client.GetSerializedPacket(Frame);

            Console.WriteLine(Output);

            StompFrame Rebuilt = Client.GetBuiltFrame(System.Text.Encoding.UTF8.GetBytes(Output));

            Console.WriteLine("");
            Console.WriteLine("------");
            Console.WriteLine("");

            Output = Client.GetSerializedPacket(Rebuilt);
            Console.WriteLine(Output);

            Console.WriteLine("");
            Console.WriteLine("------");

            NextTest("RingBuffer Data Length");

            StompRingBuffer<int> Buffer = new StompRingBuffer<int>(128);

            int[] Data = new int[64];
            for (int i = 0; i < Data.Length; i++)
                Data[i] = i + 1;

            Buffer.Write(Data);

            Console.WriteLine(string.Format("Available Write before read: {0}", Buffer.AvailableWrite));

            int[] Data2 = Buffer.Read(Buffer.AvailableRead);
            Console.WriteLine(string.Format("Available Write after read: {0}", Buffer.AvailableWrite));
            Console.WriteLine(string.Format("Lengths: {0} and {1}", Data.Length, Data2.Length));

            NextTest("Data Comparison");

            for (int i = 0; i < Math.Min(Data.Length, Data2.Length); i++)
                Console.WriteLine(string.Format("{0} {1}", Data[i], Data2[i]));

            NextTest("Seek Back 32");

            Console.WriteLine(string.Format("Seek Ptr is {0}", Buffer.Seek(-32)));
            Console.WriteLine(string.Format("Available is {0}", Buffer.AvailableRead));
            Data2 = Buffer.Read(Buffer.AvailableRead);
            Console.WriteLine(string.Format("Read out {0}", Data2.Length));
            Console.WriteLine(string.Format("Seek Ptr is {0}", Buffer.Seek(0)));

            NextTest("Old Data");

            foreach (int D in Data2)
                Console.WriteLine(string.Format("{0} ", D));

            NextTest("Write and Read");

            Buffer.Write(Data, 32);
            Buffer.Seek(-32);
            Data2 = Buffer.Read(Buffer.AvailableRead);
            Console.WriteLine(string.Format("Write 32; Read out {0}", Data2.Length));

            NextTest("Data");

            foreach (int D in Data2)
                Console.WriteLine(string.Format("{0} ", D));

            NextTest("Seek Forward");

            Console.WriteLine(string.Format("Available Read is {0}, should be 0", Buffer.AvailableRead));

            Console.WriteLine(string.Format("Write {0}", Data.Length));
            Buffer.Write(Data);

            Console.WriteLine(string.Format("Available Read is {0}", Buffer.AvailableRead));
            Buffer.Seek(10);
            Console.WriteLine(string.Format("Seek; Ptr is {0}", Buffer.Seek(0)));
            Console.WriteLine(string.Format("Available Read is {0}", Buffer.AvailableRead));

            Data2 = Buffer.Read(Buffer.AvailableRead);
            Console.WriteLine(string.Format("Read out {0}", Data2.Length, Data.Length));
            Console.WriteLine(string.Format("Available Read is {0}", Buffer.AvailableRead));

            Console.WriteLine(string.Format("Seek Ptr is {0}", Buffer.Seek(0)));

            NextTest("Data");

            foreach (int D in Data2)
                Console.WriteLine(string.Format("{0} ", D));

            Console.ReadLine();
        }