Beispiel #1
0
        public static async Task <ReturnResult> IsLogOn(AsyncCalls async, string username)
        {
            if (UserList.Find(p => p.UserName == username) == null)
            {
                UserInfo user = new UserInfo()
                {
                    UserName = username,
                    token    = async.AsyncUser
                };

                async.UserToken  = user;
                async.IsValidate = true;

                user.Nick = await async.GetNick();

                async.SetUserList(UserList);

                foreach (var item in UserList)
                {
                    item.token.AddUser(user);
                }

                async.AsyncUser.UserDisconnect += AsyncUser_UserDisconnect;

                UserList.Add(user);

                return(async.RET(true));
            }
            else
            {
                return(async.RET(false, "username not use"));
            }
        }
Beispiel #2
0
        public static async Task <ReturnResult> StartDown(AsyncCalls async, string url)
        {
            var htmldata = (await async.CR(2001, url))?[0]?.Value <byte[]>();

            if (htmldata != null)
            {
                string html = Encoding.UTF8.GetString(htmldata);

                return(async.RET(html));
            }


            return(async.RET());// or async.RET(null);
        }
Beispiel #3
0
        public async Task <ReturnResult> DownHtml(AsyncCalls async, string url)
        {
            HttpClient client = new HttpClient();

            byte[] html = await client.GetByteArrayAsync(url);

            return(async.RET(html));
        }
Beispiel #4
0
        public async Task <ReturnResult> DownHtml(AsyncCalls async, string url)
        {
            WebClient client = new WebClient();

            byte[] html = await client.DownloadDataTaskAsync(url);

            return(async.RET(html));
        }
Beispiel #5
0
        public static async Task <ReturnResult> ToMessage(AsyncCalls async, string account, string msg)
        {
            var userinfo = async.Token <UserInfo>();

            if (userinfo != null && async.IsValidate == true)
            {
                var touser = UserList.Find(p => p.UserName == account);

                if (touser != null)
                {
                    var ret = await touser.token.MakeAsync(async).MsgToUser(userinfo.UserName, msg);

                    if (ret != null)
                    {
                        return(async.RET(ret));
                    }
                }
            }

            return(async.RET());
        }
Beispiel #6
0
        public async Task <ReturnResult> TestRec(AsyncCalls async, int count)
        {
            count--;
            if (count > 1)
            {
                var x = (await async.CR(2500, count))?[0]?.Value <int>();

                if (x != null && x.HasValue)
                {
                    count = x.Value;
                }
            }

            return(async.RET(count));
        }
Beispiel #7
0
        public static async Task <ReturnResult> TestRec(AsyncCalls async, int count)
        {
            count--;
            if (count > 1)
            {
                var x = (await async.Get <IClientPacker>().TestRec(count))?[0]?.Value <int>();

                if (x != null && x.HasValue)
                {
                    count = x.Value;
                }
            }

            return(async.RET(count));
        }
Beispiel #8
0
 public static Task <ReturnResult> GetTime(AsyncCalls async)
 {
     return(Task.FromResult <ReturnResult>(async.RET(DateTime.Now)));
 }