예제 #1
0
        public async override Task <answer> getanswer(q_getservertoken question)
        {
            await Task.CompletedTask;
            var dv = dbserverinfo.FindOne(i => i.id == (int)question.chromosome && i.password == question.password);

            if (dv == null)
            {
                throw new Exception("lkfkbmfkbjfjbjgvkkbg");
            }
            else
            {
                var user = new s2user()
                {
                    callerid = question.chromosome.ToString(),
                    fullname = question.chromosome.ToString(),
                    id       = (long)question.chromosome,
                    general  = false,
                    active   = true
                };
                q2sendactivecode.changetoken(user);
                db.upsert(user, false);
                return(new q_getservertoken.done()
                {
                    token = user.token
                });
            }
        }
예제 #2
0
        internal static void changetoken(s2user user)
        {
            long newtoken = 0;

            do
            {
                newtoken = (long)((basic.random.NextDouble() * 2.0 - 1.0) * long.MaxValue);
            } while (db.exists(i => i.token == newtoken));
            user.token = newtoken;
        }
예제 #3
0
 internal static void upsert(s2user user, bool savediff)
 {
     main.Upsert(user);
     if (savediff)
     {
         var dbcontact = getcontact(user.id);
         foreach (var i in dbcontact.FindAll().ToArray())
         {
             diff.set(getdiff(i.id), user.id, difftype.update);
             mainserver.notify(i.id);
         }
     }
 }
예제 #4
0
        public async override Task <answer> getanswer(q_sendactivecode question)
        {
            await Task.CompletedTask;
            var dv = db.findone(i => i.callerid == question.callerid);

            if (dv == null)
            {
                dv = new s2user()
                {
                    callerid = question.callerid,
                    fullname = question.callerid,
                    general  = true,
                };
                changetoken(dv);
                changeactivecode(dv);
                db.upsert(dv, false);
            }
            ;
            //sms activecode to caller id
            return(new q_sendactivecode.done());
        }
예제 #5
0
 internal static void changeactivecode(s2user user)
 {
     user.activecode = "12345";// basic.random.Next(10000, 99999).ToString();
 }