protected void InitNetServer <TMsgType>(ref NetServer <TMsgType> refServer, int port,
                                         PeerActionHandler disconnectedHandler = null
                                         ) where TMsgType : struct
 {
     if (NetworkUtil.InitNetServer(ref refServer, port, this))
     {
         return;
     }
     if (disconnectedHandler != null)
     {
         refServer.OnDisconnected += disconnectedHandler;
     }
     _allServerNet.Add(refServer);
     _allNets.Add(refServer);
     _cachedAllServerNet = null;
 }
        public static bool InitNetServer <TMsgType>(ref NetServer <TMsgType> refServer, int port,
                                                    object target, string key = "") where TMsgType : struct
        {
            if (refServer != null)
            {
                return(true);
            }
            var maxIdx            = (short)(object)(TMsgType)Enum.Parse(typeof(TMsgType), "EnumCount");
            HashSet <string> tags = new HashSet <string>();

            for (short i = 0; i < maxIdx; i++)
            {
                var enumStr = ((TMsgType)(object)i).ToString();
                tags.Add(enumStr.Split('_')[0]);
            }

            refServer = new NetServer <TMsgType>(key, maxIdx, tags.ToArray(), target);
            refServer.Listen(port);
            return(false);
        }