//public static void TestRelease(HoxisConnection conn) { Ret ret; lock (conn) _connReception.Release(conn, out ret); }

        #region management

        //public static bool ManageCluster(ManageOperation op, HoxisUser sponsor)
        //{
        //    switch (op)
        //    {
        //        case ManageOperation.Create:
        //            string cid = FF.StringAppend(sponsor.userID.ToString(), "@", SF.GetTimeStamp().ToString());
        //            if (_clusters.ContainsKey(cid)) { Console.WriteLine("[error]Create cluster: cluster {0} already exists", cid); return false; }
        //            lock (_clusters)
        //            {
        //                HoxisCluster hc = new HoxisCluster(cid);
        //                _clusters.Add(cid, hc);
        //                Ret ret;
        //                hc.UserJoin(sponsor, out ret);
        //                if (ret.code != 0) { Console.WriteLine("[warning]Create cluster: {0}", ret.desc); return false; }
        //            }
        //            break;
        //        case ManageOperation.Join:
        //            // todo Call matching sdk, get a cluster
        //            break;
        //        case ManageOperation.Leave:

        //            break;
        //        case ManageOperation.Destroy:

        //            break;
        //    }
        //    return true;
        //}

        #endregion

        private void ProcessAffair(object state)
        {
            KV <int, object> affair = (KV <int, object>)state;

            switch (affair.key)
            {
            case C.AFFAIR_RELEASE_CONNECTION:
                Ret             ret;
                HoxisConnection conn = (HoxisConnection)affair.val;
                lock (conn) { _connReception.Release(conn, out ret); }
                if (ret.code != 0)
                {
                    _logger.LogWarning(ret.desc, "Affair"); return;
                }
                break;
            }
            _logger.LogInfo(FF.StringFormat("{0} processed", affair.key), "Affair", true);
        }
 /// <summary>
 /// Begin accepting socket connection within thread
 /// </summary>
 public void BeginAccept()
 {
     _acceptThread = new Thread(() =>
     {
         while (true)
         {
             Socket socket = _socket.Accept();
             _logger.LogInfo(FF.StringAppend("accept new client: ", socket.RemoteEndPoint.ToString()), "Server", true);
             Ret ret;
             HoxisConnection conn = _connReception.Request(socket, out ret);
             if (ret.code != 0)
             {
                 _logger.LogWarning(ret.desc, socket.RemoteEndPoint.ToString()); continue;
             }
             _logger.LogInfo("request successful", conn.clientIP);
         }
     });
     _acceptThread.Start();
     _logger.LogInfo("accept begin...", "Server", true);
 }