Ejemplo n.º 1
0
    void Update()
    {
        List <TcpClientState> toProcess;

        lock (Lock) {
            toProcess = new List <TcpClientState> (inbox);
            inbox.Clear();
        }
        if (toProcess != null)
        {
            foreach (TcpClientState client in toProcess)
            {
                List <string> msgs = client.Prot.swap_msgs();
                msgs.ForEach(delegate(string msg) {
                    var sw = new Stopwatch();
                    sw.Start();
                    var t0          = sw.ElapsedMilliseconds;
                    string response = rpc.HandleMessage(msg);
                    var t1          = sw.ElapsedMilliseconds;
                    byte[] bytes    = prot.pack(response);
                    var t2          = sw.ElapsedMilliseconds;
                    server.Send(client.TcpClient, bytes);
                    var t3 = sw.ElapsedMilliseconds;
                    debugProfilingData ["handleRpcRequest"] = t1 - t0;
                    debugProfilingData ["packRpcResponse"]  = t2 - t1;
                });
            }
        }
    }
Ejemplo n.º 2
0
 void Update()
 {
     foreach (TcpClientState client in inbox.Values)
     {
         List <string> msgs = client.Prot.swap_msgs();
         msgs.ForEach(delegate(string msg) {
             var sw = new Stopwatch();
             sw.Start();
             var t0          = sw.ElapsedMilliseconds;
             string response = rpc.HandleMessage(msg);
             var t1          = sw.ElapsedMilliseconds;
             byte[] bytes    = prot.pack(response);
             var t2          = sw.ElapsedMilliseconds;
             server.Send(client.TcpClient, bytes);
             var t3 = sw.ElapsedMilliseconds;
             debugProfilingData ["handleRpcRequest"] = t1 - t0;
             debugProfilingData ["packRpcResponse"]  = t2 - t1;
             TcpClientState internalClientToBeThrowAway;
             string tcpClientKey = client.TcpClient.Client.RemoteEndPoint.ToString();
             inbox.TryRemove(tcpClientKey, out internalClientToBeThrowAway);
         });
     }
 }