Exemplo n.º 1
0
 public static bool Connect(string host, int port)
 {
     Client          = new RPCClient();
     Client.OutTime  = 5000; //超时时间5秒
     Client.Disconn += Client_Disconn;
     return(Client.Connection(host, port));
 }
Exemplo n.º 2
0
 public static void Connect()
 {
     Net       = new RPCClient();
     IsConnect = Net.Connection("127.0.0.1", 1000);
     if (IsConnect)
     {
         Net.Disconn += Net_Disconn;
         Net.RegModule(CallBack);
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            RPCClient client = new RPCClient();

            if (client.Connection("127.0.0.1", 3000))
            {
                client.Disconn += Client_Disconn;
                client.MsgOut  += Client_MsgOut;
                client.RegModule(new Client());
                Console.Write("输入你的昵称:");
                if (client.Call <TalkService, bool>(p => p.IsLogIn(Console.ReadLine())))
                {
                    while (true)
                    {
                        string msg = Console.ReadLine();
                        client.Call <TalkService>(p => p.SendALL(msg));
                    }
                }
            }
        }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     RPCClient client = new RPCClient();
     if (client.Connection("127.0.0.1", 3000))
     {
         client.Disconn += Client_Disconn;
         client.MsgOut += Client_MsgOut;
         client.RegModule(new Client());
         Console.Write("输入你的昵称:");
         if (client.Call<TalkService, bool>(p => p.IsLogIn(Console.ReadLine())))
         {
             while (true)
             {                       
                 string msg = Console.ReadLine();
                 client.Call<TalkService>(p => p.SendALL(msg));
               
             }
         }
     }
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            RPCClient client = new RPCClient();

            if (client.Connection("127.0.0.1", 3000))
            {
                client.OutTime  = 10000000;
                client.Disconn += Client_Disconn;
                client.MsgOut  += Client_MsgOut;
                client.RegModule(new Client());
                Console.Write("输入你的昵称:");

                var IServer = client.GetRPC <TalkService>();

                if (IServer.IsLogIn(Console.ReadLine()))
                {
                    while (true)
                    {
                        string msg = Console.ReadLine();
                        IServer.SendALL(msg);
                    }
                }
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            RPCClient client = new RPCClient();
            if (client.Connection("127.0.0.1", 3000))
            {
                client.OutTime = 10000000;
                client.Disconn += Client_Disconn;
                client.MsgOut += Client_MsgOut;
                client.RegModule(new Client());
                Console.Write("输入你的昵称:");

                var IServer = client.GetRPC<TalkService>();

                if (IServer.IsLogIn(Console.ReadLine()))
                {
                    while (true)
                    {                       
                        string msg = Console.ReadLine();
                        IServer.SendALL(msg);
                    
                    }
                }
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {


            RPCClient client = new RPCClient();
            if (client.Connection("127.0.0.1", 9952))
            {
                client.OutTime = 2000;
                client.Disconn += Client_Disconn;
                client.RegModule(new ClientCall());

                Console.WriteLine("input userName:"******"123123")))
                {
                    Console.WriteLine("LogOn Is OK");

                    while (true)
                    {
                        string msg = Console.ReadLine();

                        client.Call<ServerClass>(p => p.SendAll(msg));


                        DateTime time = client.Call<ServerClass, DateTime>(p => p.GetServerTime());

                        Console.WriteLine("Serve time is " + time);

                        int value = 0;

                        client.Call<ServerClass>(p => p.OutRandom(out value));

                        Console.WriteLine("Random value is " + value);

                        Data x = new Data()
                        {
                            Name = "II",
                            Value = 0
                        };

                        var v = client.Call<ServerClass, Data>(p => p.Return(x));

                        Console.WriteLine("Data Name " + v.Name);

                        var l = client.Call<ServerClass, int>(p => p.RecComputer(10)); //这叫递归吗? 代价太大,深度最好别超过5层 实在没办法记得设置outtime

                        Console.WriteLine("Rec computer value:" + l);

                        var server = client.GetRPC<ServerClass>();

                        var ary = server.array(new string[] { "123", "123" }); //Array + string


                        System.Diagnostics.Stopwatch stop = new System.Diagnostics.Stopwatch();
                        stop.Start();
                        //int j = 0;
                        for (int i = 0; i < 10000; i++)
                        {
                            x=server.Return(x);
                        }
                        stop.Stop();
                        Console.WriteLine("Time:" + stop.ElapsedMilliseconds + " J:" + x.Value);



                    }

                }

            }

        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            RPCClient client = new RPCClient();

            if (client.Connection("127.0.0.1", 9952))
            {
                client.OutTime  = 2000000;
                client.Disconn += Client_Disconn;
                client.RegModule(new ClientCall());

                Console.WriteLine("input userName:"******"123123"))
                {
                    Console.WriteLine("LogOn Is OK");

                    while (true)
                    {
                        string msg = Console.ReadLine();

                        client.GetRPC <ServerClass>().SendAll(msg);


                        DateTime time = client.GetRPC <ServerClass>().GetServerTime();

                        Console.WriteLine("Serve time is " + time);

                        int value = 0;

                        client.GetRPC <ServerClass>().OutRandom(out value);

                        Console.WriteLine("Random value is " + value);

                        Data x = new Data()
                        {
                            Name = "II"
                        };

                        var v = client.GetRPC <ServerClass>().Return(x);

                        Console.WriteLine("Data Name " + v.Name);

                        var l = client.GetRPC <ServerClass>().RecComputer(10); //这叫递归吗? 代价太大,深度最好别超过5层 实在没办法记得设置outtime

                        Console.WriteLine("Rec computer value:" + l);


                        var arry = client.GetRPC <ServerClass>().array(new string[] { "123", "321" }); //array


                        var arry2 = client.GetRPC <ServerClass>().array(new Data[] { new Data()
                                                                                     {
                                                                                         Name = "1"
                                                                                     }, new Data()
                                                                                     {
                                                                                         Name = "2"
                                                                                     } });               // class array

                        var arry3 = client.GetRPC <ServerClass>().array(new int[] { 123, 321 });         //int array

                        var arry4 = client.GetRPC <ServerClass>().array(new float[] { 123.0f, 321.0f }); //int array
                    }
                }
            }
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            LogAction.LogOut += LogAction_LogOut;
            RPCClient client = new RPCClient();

            if (client.Connection("127.0.0.1", 3000))
            {
                client.OutTime  = 10000;
                client.Disconn += Client_Disconn;
                client.RegModule(new Client());
                Console.Write("输入你的昵称:");

                var service = client.GetRPC <ITalkService>();

                if (service.IsLogIn(Console.ReadLine()))
                {
                    while (true)
                    {
                        //string msg = Console.ReadLine();



                        System.Diagnostics.Stopwatch stop = new System.Diagnostics.Stopwatch();
                        stop.Start();

                        int j = 0;

                        for (int i = 0; i < 10000; i++)
                        {
                            j = service.value(i, j);
                        }
                        stop.Stop();

                        Console.WriteLine("sync call ms:" + stop.ElapsedMilliseconds);

                        stop.Reset();
                        stop.Start();

                        j = 0;
                        Parallel.For(0, 10000, i =>
                        {
                            j = service.value(i, j);
                        });

                        stop.Stop();

                        Console.WriteLine("Parallel sync call ms:" + stop.ElapsedMilliseconds);

                        stop.Reset();
                        stop.Start();

                        Parallel.For(0, 10000, i =>
                        {
                            service.notReturn(i);
                        });


                        stop.Stop();

                        Console.WriteLine("Parallel not return async call ms:" + stop.ElapsedMilliseconds);
                        service.SendALL(Console.ReadLine());
                    }
                }
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            LogAction.LogOut += LogAction_LogOut;
            RPCClient client = new RPCClient();

            if (client.Connection("127.0.0.1", 9952))
            {
                client.OutTime  = 8000;
                client.Disconn += Client_Disconn;
                client.RegModule(new ClientCall());

                Console.WriteLine("input userName:"******"123123"))
                {
                    Console.WriteLine("LogOn Is OK");

                    while (true)
                    {
                        string msg = Console.ReadLine();

                        server.SendAll(msg);


                        DateTime time = server.GetServerTime();

                        Console.WriteLine("Serve time is " + time);

                        int value = 0;

                        server.OutRandom(out value);

                        Console.WriteLine("Random value is " + value);

                        Data x = new Data()
                        {
                            Name  = "II",
                            Value = 0
                        };


                        var v = server.Return(x);

                        Console.WriteLine("Data Name " + v.Name);

                        var ary = server.array(new string[] { "123", "123" }); //Array + string


                        System.Diagnostics.Stopwatch stop = new System.Diagnostics.Stopwatch();
                        stop.Start();
                        //int j = 0;
                        for (int i = 0; i < 10000; i++)
                        {
                            x = server.Return(x);
                        }
                        stop.Stop();
                        Console.WriteLine("Time:" + stop.ElapsedMilliseconds + " J:" + x.Value);


                        Console.ReadLine();

                        int mm = 0;
                        int xx = 1;
                        stop.Reset();
                        stop.Start();
                        //int j = 0;
                        for (int i = 0; i < 10000; i++)
                        {
                            server.TestOutAndRef(out mm, ref xx);
                        }
                        stop.Stop();
                        Console.WriteLine("Time:" + stop.ElapsedMilliseconds + " mm:" + mm + " xx:" + xx);
                    }
                }
                else
                {
                    Console.WriteLine("password error");
                    Console.ReadLine();
                }
            }
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {


            RPCClient client = new RPCClient();
            if (client.Connection("127.0.0.1", 9952))
            {
                client.OutTime = 2000000;
                client.Disconn += Client_Disconn;
                client.RegModule(new ClientCall());

                Console.WriteLine("input userName:"******"123123"))
                {
                    Console.WriteLine("LogOn Is OK");

                    while (true)
                    {
                        string msg = Console.ReadLine();

                        client.GetRPC<ServerClass>().SendAll(msg);


                        DateTime time = client.GetRPC<ServerClass>().GetServerTime();

                        Console.WriteLine("Serve time is " + time);

                        int value = 0;

                        client.GetRPC<ServerClass>().OutRandom(out value);

                        Console.WriteLine("Random value is " + value);

                        Data x = new Data()
                        {
                            Name = "II"
                        };

                        var v = client.GetRPC<ServerClass>().Return(x);

                        Console.WriteLine("Data Name " + v.Name);

                        var l = client.GetRPC<ServerClass>().RecComputer(10); //这叫递归吗? 代价太大,深度最好别超过5层 实在没办法记得设置outtime

                        Console.WriteLine("Rec computer value:" + l);


                        var arry = client.GetRPC<ServerClass>().array(new string[] { "123", "321" }); //array


                        var arry2 = client.GetRPC<ServerClass>().array(new Data[] { new Data() { Name = "1" }, new Data() { Name = "2" } }); // class array

                        var arry3 = client.GetRPC<ServerClass>().array(new int[] { 123, 321 }); //int array

                        var arry4 = client.GetRPC<ServerClass>().array(new float[] { 123.0f, 321.0f }); //int array
                    }

                }

            }

        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            RPCClient client = new RPCClient();

            if (client.Connection("127.0.0.1", 9952))
            {
                client.OutTime  = 2000;
                client.Disconn += Client_Disconn;
                client.RegModule(new ClientCall());

                Console.WriteLine("input userName:"******"123123")))
                {
                    Console.WriteLine("LogOn Is OK");

                    while (true)
                    {
                        string msg = Console.ReadLine();

                        client.Call <ServerClass>(p => p.SendAll(msg));


                        DateTime time = client.Call <ServerClass, DateTime>(p => p.GetServerTime());

                        Console.WriteLine("Serve time is " + time);

                        int value = 0;

                        client.Call <ServerClass>(p => p.OutRandom(out value));

                        Console.WriteLine("Random value is " + value);

                        Data x = new Data()
                        {
                            Name  = "II",
                            Value = 0
                        };

                        var v = client.Call <ServerClass, Data>(p => p.Return(x));

                        Console.WriteLine("Data Name " + v.Name);

                        var l = client.Call <ServerClass, int>(p => p.RecComputer(10)); //这叫递归吗? 代价太大,深度最好别超过5层 实在没办法记得设置outtime

                        Console.WriteLine("Rec computer value:" + l);

                        var server = client.GetRPC <ServerClass>();

                        var ary = server.array(new string[] { "123", "123" }); //Array + string


                        System.Diagnostics.Stopwatch stop = new System.Diagnostics.Stopwatch();
                        stop.Start();
                        //int j = 0;
                        for (int i = 0; i < 10000; i++)
                        {
                            x = server.Return(x);
                        }
                        stop.Stop();
                        Console.WriteLine("Time:" + stop.ElapsedMilliseconds + " J:" + x.Value);
                    }
                }
            }
        }