protected override void Receiving(byte[] data, IPEndPoint e)
 {
     try
     {
         base.Receiving(data, e);
         NetworkPackageCompress newPack = new NetworkPackageCompress();
         newPack.DeserializeBin(data);
         newPack.AddTarget(e.Address.ToString(), e.Port);
         CommingPackage(newPack);
     }
     catch (Exception ee)
     {
         SetEvent(DSEvent.Error, "Receive Package error" + ee.ToString());
     }
 }
        //Decode Incomming package
        public override void ReceiveFinsh(StateObject state)
        {
            base.ReceiveFinsh(state);
            NetworkPackageCompress np = new NetworkPackageCompress();

            np.DeserializeBin(state.data.ToArray());
            var cmd = np.Get <string>("CMD");

            if (cmd != null)
            {
                AddMsg("CMD: " + cmd);
                switch (cmd)
                {
                case "NeedConnectedIPs":
                    var list = GetConnectedIP();
                    packageNeedToSend.Add("ConnectedIPs", list);
                    packageNeedToSend.SetTarget(state.workSocket);     //send back to original
                    SetNextTask(MyTask.ServerSend);
                    break;

                case "SendCMDtoALL":
                {
                    var dat = np.Get <string>("DAT");
                    packageNeedToSend.Add("CMD", dat);
                    SetNextTask(MyTask.ServerBoardCast);
                }
                break;

                case "SendCMDtoIP":
                {
                    var dat     = np.Get <string>("DAT");
                    var ip      = np.Get <string>("IP");
                    var sockets = GetSocketsByIP(ip);
                    packageNeedToSend.Add("CMD", dat);
                    packageNeedToSend.SetTargets(sockets);
                    SetNextTask(MyTask.ServerMultiSend);
                }
                break;
                }
            }
        }
        public override void ReceiveFinsh(StateObject state)
        {
            base.ReceiveFinsh(state);
            NetworkPackageCompress np = new NetworkPackageCompress();

            np.DeserializeBin(state.data.ToArray());
            var dat = np.Get <List <string> >("ConnectedIPs");

            if (dat != null)
            {
                connectedIP = dat;
                SetEvent(DSEvent.ClientSendAndReceive);
                AddMsg("--> ConnectedIPs list");
            }
            var cmd = np.Get <string>("CMD");

            if (cmd != null)
            {
                AddMsg("--> CMD:" + cmd);
            }
        }