コード例 #1
0
ファイル: RemoteService.cs プロジェクト: yunjoker/Scut
 /// <summary>
 /// Create tcp proxy
 /// </summary>
 /// <param name="proxyId"></param>
 /// <param name="host"></param>
 /// <param name="port"></param>
 /// <param name="heartInterval"></param>
 /// <returns></returns>
 public static RemoteService CreateTcpProxy(string proxyId, string host, int port, int heartInterval)
 {
     var client = new SocketRemoteClient(host, port, heartInterval);
     client.Callback += OnNetTcpCallback;
     var proxy = new RemoteService(proxyId, client);
     client.RemoteTarget = proxy;
     return proxy;
 }
コード例 #2
0
ファイル: SocketTest.cs プロジェクト: LeeWangyeol/Scut
        public void Remote()
        {
            SocketRemoteClient client = new SocketRemoteClient("127.0.0.1", port, 30);
            client.Callback += OnReceived;
            client.Connect();
            Trace.WriteLine("LocalAddress:" + client.LocalAddress);
            Trace.Flush();
            Task.Factory.StartNew(() =>
            {
                client.Send("hello").Wait();
                client.Wait();
                Assert.AreEqual(msg, "hello");
            }).Wait();

            Task.Factory.StartNew(() =>
           {
               client.Send("hello2").Wait(1000);
               client.Wait();
               Assert.AreEqual(msg, "hello2");
           }).Wait();

            client.Close();

        }