Esempio n. 1
0
        //private static HproseClient orderClient;
        static ServiceProvider()
        {
            hpClient = HproseClient.Create(string.Format("tcp://{0}", ConfigurationManager.AppSettings["hproseIpPort"])) as HproseTcpClient;
            hpClient.AddFilter(new HproseTokenFilter(ConfigurationManager.AppSettings["hproseSecretKey"]));

            //orderClient = HproseClient.Create(string.Format("tcp://{0}", ConfigurationManager.AppSettings["orderServicesIpPort"]));
        }
Esempio n. 2
0
        private void TCP_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FileStream   fileStream = new FileStream(@"D:\Program Files\桌面\12112\QrCodeConfig.json", FileMode.Open);
                StreamReader sw         = new StreamReader(fileStream);
                var          jsonvar    = sw.ReadToEnd();
                sw.Close();
                sw.Dispose();
                fileStream.Close();
                fileStream.Dispose();
                QrCodeOptions qqq = JsonConvert.DeserializeObject <QrCodeOptions>(jsonvar);


                var json = JsonConvert.SerializeObject(qqq);


                string       tcp    = Queryservice.GetTcpUrl();
                HproseClient client = HproseClient.Create(tcp);

                var jsonvar22 = client.Invoke <string>("Expjson", new object[] { });

                //var text = @"{"qrCodeCustoms":[{"QrCodeTag":1,"QrCodeStyle":4,"ColorBrush":"0, 0, 0","QrCodeSize":0},{"QrCodeTag":2,"QrCodeStyle":1,"ColorBrush":"0, 0, 0","QrCodeSize":0},{"QrCodeTag":3,"QrCodeStyle":6,"ColorBrush":"0, 0, 0","QrCodeSize":0},{"QrCodeTag":4,"QrCodeStyle":1,"ColorBrush":"0, 0, 0","QrCodeSize":1}],"QrCodeTypeEnum":2,"LogoImgPath":"","IsTopLogoImg":false,"DpiInch":600,"QrCodeWidthMM":200,"QuietZoneModule":1,"ErrorCorrectionLevel":2,"QrText":"https://www.hao123.com","IsTypeSize":true,"IsQrCodeAutoSize":true,"QrCodePixelWidth":800}";
                byte[] bytevar = client.Invoke <byte[]>("Encoder", new object[] { json });
            }
            catch (Exception ex)
            {
                throw;
            }

            // byte[] bytevar = client.Invoke<byte[]>("Encoder", new object[] { jsonvar });
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            HproseClient client = HproseClient.Create("tcp4://127.0.0.1:4321/");

            hello = client.UseService <IHello>();
            Console.WriteLine("TCP");
            Console.WriteLine(hello.Hello("World"));
            Test("World");
            Test("".PadRight(512, '$'));
            Test("".PadRight(1024, '$'));
            Test("".PadRight(2 * 1024, '$'));
            Test("".PadRight(4 * 1024, '$'));
            Test("".PadRight(8 * 1024, '$'));
            Test("".PadRight(16 * 1024, '$'));
            Test("".PadRight(32 * 1024, '$'));
            Test("".PadRight(64 * 1024, '$'));

            client = HproseClient.Create("http://localhost:8888/");
            hello  = client.UseService <IHello>();
            Console.WriteLine("HTTP");
            Console.WriteLine(hello.Hello("World"));
            Test("World");
            Test("".PadRight(512, '$'));
            Test("".PadRight(1024, '$'));
            Test("".PadRight(2 * 1024, '$'));
            Test("".PadRight(4 * 1024, '$'));
            Test("".PadRight(8 * 1024, '$'));
            Test("".PadRight(16 * 1024, '$'));
            Test("".PadRight(32 * 1024, '$'));
            Test("".PadRight(64 * 1024, '$'));
            Console.ReadKey();

//            client.Invoke<string>("hello", new Object[] { "Async World" }, result => Console.WriteLine(result));
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            HproseClient client = HproseClient.Create("tcp://127.0.0.1:4321");

            client.Filter = new MyClientFilter();
            IStub stub = client.UseService <IStub>();

            Console.WriteLine(stub.Inc());
            Console.WriteLine(stub.Inc());
            Console.WriteLine(stub.Inc());
            Console.WriteLine(stub.Inc());
            Console.ReadKey();
        }
Esempio n. 5
0
        private static string server_port = "0000";         // *服務器端口,請連絡服務器管理員取得正確值。

        private static void Main(string[] args)
        {
            HproseClient _http = HproseClient.Create($"http://{server_ip}:{server_port}");

            // 函式登錄
            API.IHello                hello                = _http.UseService <API.IHello>();
            API.IVerify               verify               = _http.UseService <API.IVerify>();
            API.IReadStateOfEnable    readStateOfEnable    = _http.UseService <API.IReadStateOfEnable>();
            API.IReadScriptRemain     readScriptRemain     = _http.UseService <API.IReadScriptRemain>();
            API.IReadQueryLastOperate readQueryLastOperate = _http.UseService <API.IReadQueryLastOperate>();
            API.IReadFlowOfOperate    readFlowOfOperate    = _http.UseService <API.IReadFlowOfOperate>();
            API.IReadGetAnswer        readGetAnswer        = _http.UseService <API.IReadGetAnswer>();
            API.IWriteCommand         writeCommand         = _http.UseService <API.IWriteCommand>();
            // 函式測試
            string empty = "";

            Console.WriteLine("[RollBall Game API]");
            try
            {
                int requet_remain_limit = 700;      // 注意:取得服務間隔時間低於500豪秒會回應錯誤: (403) 禁止
                Console.WriteLine("");
                Console.WriteLine($"Hello: { hello.Hello("World")}");
                Thread.Sleep(requet_remain_limit);  // 程式實做時你可以使用 Timer
                Console.WriteLine($"Verify: {verify.Verify(new string[] { "127.0.0.1", "*****@*****.**", "阿管先生", "發財公司", "我在珠海市" })}");
                Thread.Sleep(requet_remain_limit);
                Console.WriteLine($"ReadStateOfEnable: {string.Join(", ", readStateOfEnable.ReadStateOfEnable(empty))}");
                Thread.Sleep(requet_remain_limit);
                Console.WriteLine($"ReadScriptRemain: {string.Join(", ", readScriptRemain.ReadScriptRemain(empty))}");
                Thread.Sleep(requet_remain_limit);
                Console.WriteLine($"ReadQueryLastOperate: {string.Join(", ", readQueryLastOperate.ReadQueryLastOperate(empty))}");
                Thread.Sleep(450);                  // 遠端伺服器傳回一個錯誤: (403) 禁止
                Console.WriteLine($"ReadFlowOfOperate: {string.Join(", ", readFlowOfOperate.ReadFlowOfOperate(empty))}");
                Thread.Sleep(requet_remain_limit);
                Console.WriteLine($"ReadGetAnswer: {string.Join(", ", readGetAnswer.ReadGetAnswer(empty))}");
                Thread.Sleep(requet_remain_limit);
                Console.WriteLine($"WriteCommand: {writeCommand.WriteCommand("0")}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("Ending, Press any key to exit!");
            Console.ReadKey();
        }
Esempio n. 6
0
 public AsyncInvokeContextBase(HproseClient client, string functionName, object[] arguments, HproseErrorEvent errorCallback, Type returnType, bool byRef, HproseResultMode resultMode, bool simple)
 {
     this.client = client;
     this.functionName = functionName;
     this.arguments = arguments;
     this.errorCallback = (errorCallback == null) ? client.OnError : errorCallback;
     this.returnType = returnType;
     this.byRef = byRef;
     this.resultMode = resultMode;
     this.simple = simple;
     this.syncContext = HproseClient.SynchronizationContext;
     this.context = new HproseClientContext(client);
 }
Esempio n. 7
0
 internal AsyncInvokeContext1(HproseClient client, string functionName, object[] arguments, HproseCallback1 callback, HproseErrorEvent errorCallback, Type returnType, HproseResultMode resultMode, bool simple)
     : base(client, functionName, arguments, errorCallback, returnType, false, resultMode, simple)
 {
     this.callback = callback;
 }
Esempio n. 8
0
 internal AsyncInvokeContextBase(HproseClient client, string functionName, object[] arguments, HproseErrorEvent errorCallback, Type returnType, bool byRef, HproseResultMode resultMode)
 {
     this.client = client;
     this.functionName = functionName;
     this.arguments = arguments;
     this.errorCallback = errorCallback;
     this.returnType = returnType;
     this.byRef = byRef;
     this.resultMode = resultMode;
     this.syncContext = HproseClient.SynchronizationContext;
 }