コード例 #1
0
    static void Main(string[] args)
    {
        string host = "188.40.137.215";
        int    port = 23323;

        //string host = "99.229.37.128";
        // int port = 9990;
        RPCTest = DoSomething;

        RPCTest.Invoke(5, 4);
        byte    rpcID;
        RPCTest test  = new RPCTest(2);
        RPCTest test2 = new RPCTest(4);
        Type    type  = typeof(RPCTest);
        int     x1    = 5;
        int     x2    = 3;

        object[] obj = { 1, 2 };

        MethodInfo[] methods = type.GetMethods();

        for (int i = 0; i < methods.Count(); i++)
        {
            if (methods[i].IsDefined(typeof(MMORPC), out rpcID))
            {
                Console.WriteLine("Registerd Method with RPC ID =  " + rpcID);
                methods[i].Invoke(test, obj);
            }
        }
        Console.WriteLine("Connected to Server [Host = " + host + " ] [Port = " + port + Environment.NewLine);
        clientCore.InitializeClient(host, port);

        clientCore.onMovementSync  += OnMovementSync;
        clientCore.onChatResponse  += onChatResponse;
        clientCore.onLoginResponse += OnLoginResponse;
        clientCore.Connect();
        Thread thread = new Thread(new ThreadStart(KeyListen));

        thread.Start();
        while (true)
        {
            switch (Console.ReadLine().ToLower())
            {
            case "l": tbLogin_Click(); break;

            case "m": new Thread(new ThreadStart(SpamMovePackets)).Start(); break;
            }
        }
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: scottishclaymore/CallBox
        public static void PerformanceTest()
        {
            int repeats = 10000000;
            TimeSpan baseTime = TimeSpan.MinValue;

            Action<string, Action> test = (n, t) =>
                {
                    Console.Write(n + ":");
                    DateTime startTime;
                    TimeSpan result;
                    startTime = DateTime.Now;
                    for (int j = 0; j < repeats; j++)
                        t();
                    result = DateTime.Now - startTime;
                    var spaces = new String(' ', 20 - n.Length);
                    if (baseTime == TimeSpan.MinValue)
                    {
                        baseTime = result;
                        Console.WriteLine(spaces + result.ToString());
                    }
                    else
                    {
                        Console.WriteLine(String.Format("{0}{1} {2}ns",
                            spaces,
                            result.ToString(),
                            (result - baseTime).TotalMilliseconds / repeats * 1000000
                            ));
                    }
                };

            RPCTest tester = new RPCTest();
            EventTest et = new EventTest();
            et.ev1 += () => tester.IncI();
            byte[] bytes = Encoding.UTF8.GetBytes("[\"IncI\",null]");
            ClassBox callbox = ClassBox.Get(tester.GetType());
            JsonDecoder d = new JsonDecoder();
            d.Parse(bytes);

            var dynamicFunc = tester.GetType().GetMethod("IncI").CreateDynamicFunc();
            var eventFunc = et.GetType().GetEvent("ev1").CreateDynamicFunc();

            test("Direct", () => tester.IncI());
            test("DynamicFunc", () => dynamicFunc(tester, null));
            test("DynamicFunc(Event)", () => eventFunc(et, null));
            test("CallBox(Direct)", () => callbox.Call(tester, "IncI", null));
            test("CallBox", () => callbox.SerializedCall(tester, d));
            test("CallBox(Full)", () => callbox.SerializedCall(tester, d, bytes));
        }