Пример #1
0
        public bool loginToServer(string userID)
        {
            if (_logined)
            {
                return(true);
            }
            if (_UIControl.SyncCheckUserExists(userID))
            {
                return(false);
            }
            if (_PolicyBroadcastThread != null)
            {
                return(false);
            }


            _PolicyBroadcastThread = new Thread((obj) => {
                while (true)
                {
                    UserPolicyData policyData = new UserPolicyData();
                    policyData.UserID         = obj as string;
                    _UIControl.SyncGetSelfPolicyData(ref policyData);
                    _UIControl.SyncUpdatePolicyList(ref policyData);
                    //Console.WriteLine(policyData.ToString());
                    Message msg = new Message();
                    msg.SetCommand(3100, LOGMSGID);
                    MessageV2BuilderHelper helper = new MessageV2BuilderHelper();
                    helper.WriteUserPolicyData2Msg(policyData);
                    msg.setMsgBody(helper.GetMsgBody());
                    _server.conBroadcast(msg, PacketHeader.ExpoDealType.InterGroup);
                    //Thread.Sleep(500);
                    if (_policySyncWaitEvent.WaitOne(1000))
                    {
                        //收到信号退出当前线程
                        return;
                    }
                }
            });
            _PolicyBroadcastThread.Start(userID);
            _userID  = userID;
            _logined = true;

            return(_logined);
        }