private void HandlePicMessage(DefaultPackageInfo packageInfo)
 {
     Logger.Write("Socket get server image");
     using (MemoryStream stream = new MemoryStream(packageInfo.Body))
     {
         Bitmap img = new Bitmap(stream);
         OnReceiveCodeCommand?.Invoke(img);
     }
 }
        private void DispatchMessage(DefaultPackageInfo packageInfo)
        {
            switch (packageInfo.Key)
            {
            case CommandName.CODE:
                HandlePicMessage(packageInfo);
                break;

            case CommandName.AUTH:
                HandleTextMessage(packageInfo);
                break;

            case CommandName.UNKNOW:
                HandleServerMessage("unknow command");
                break;
            }
        }
        private void HandleTextMessage(DefaultPackageInfo packageInfo)
        {
            string msg = Encoding.UTF8.GetString(packageInfo.Body);

            Logger.Write("Socket get server response:" + msg);

            string accountName = "";
            string pwd         = "";

            string[] pair = msg.Split(':');
            if (pair.Length > 0)
            {
                accountName = pair[0];
            }
            if (pair.Length > 1)
            {
                pwd = pair[1];
            }

            OnReceiveAuthCommand?.Invoke(accountName, pwd);
        }