public override void DoCommand()
        {
            byte[]       content    = Decode.DecodeFirstContendBtyes(bytes);
            LoginInfo    myInfo     = DataDo.Json2Object <LoginInfo>(content);
            string       strContent = "SELECT * FROM counter where id=" + myInfo.id + " ;";
            PersonalInfo user       = SqlConn.Select(strContent);

            if (user != null)
            {
                if (user.password == myInfo.passWord)
                {
                    Console.WriteLine("用户登陆成功");
                    Server.AddUser(myInfo.id, conn);
                    conn.ID = myInfo.id;                    //客户端的id作为属性存起来了便于访问

                    user.status = (int)PersonStatus.OnLine; //在线
                    PersonalInfo.ChangeStatusInfo(int.Parse(conn.ID), "", (int)PersonStatus.OnLine);
                    conn.SendBts(Incode.IncodeFirstCommand(type, DataDo.Object2Json(user)));
                }
                else
                {
                    Console.WriteLine("密码错误");
                    //回客户端消息
                }
            }
            else
            {
                Console.WriteLine("账号不存在");
                //回客户端消息
            }
        }
        public override void DoCommand()
        {
            int    id                   = BitConverter.ToInt32(bytes, 8);
            string strContent           = "SELECT * from  friends right JOIN counter ON friends.f_id=counter.id where friends.user_id = " + id + " ORDER BY status DESC;";
            List <PersonalInfo> friends = SqlConn.FindFriends(strContent);

            Console.WriteLine("用户:" + id + "的好友数:" + friends.Count);
            conn.SendBts(Incode.IncodeFirstCommand(type, DataDo.Object2Json(friends)));
        }
Beispiel #3
0
        public override void DoCommand()
        {
            LoginInfo myInfo = DataDo.Json2Object <LoginInfo>(Decode.DecodeFirstContendBtyes(bytes));
            string    id     = SqlConn.Insert(myInfo.userName, myInfo.passWord); // 添加到数据库 通过访问数据库获取自动分配的id

            Server.AddUser(id, conn);                                            //添加到服务器连接字典里去
            conn.ID = id;                                                        //客户端的id作为属性存起来了便于访问
            //Console.WriteLine("获取id:" + id);
            string       strContent = "SELECT * FROM counter where id=" + id + " ;";
            PersonalInfo user       = SqlConn.Select(strContent);

            if (user != null)
            {
                //Console.WriteLine("用户登陆成功");
                user.status = (int)PersonStatus.OnLine;//在线(发送数据修改)
                PersonalInfo.ChangeStatusInfo(int.Parse(conn.ID), "", (int)PersonStatus.OnLine);
                conn.SendBts(Incode.IncodeFirstCommand(type, DataDo.Object2Json(user)));
            }
        }
 /// <summary>
 /// 查找好友
 /// </summary>
 public static void SelectFriendList()//加载在线好友列表
 {
     byte[] select = Incode.IncodeFirstCommand(TYPE, BitConverter.GetBytes(NetStart.myInfo.id));
     NetStart.SendContend(select);//发送查好友命令到服务器
     Debug.Log("查找好友命令发送");
 }
Beispiel #5
0
 public static void Registe_Send(LoginInfo info)
 {
     NetStart.SendContend(Incode.IncodeFirstCommand(TYPE, DataDo.Object2Json <LoginInfo>(info)));
 }
Beispiel #6
0
 /// <summary>
 /// 排行榜查询
 /// </summary>
 public static void Rank_Send()
 {
     byte[] byt = System.Text.Encoding.UTF8.GetBytes("");
     NetStart.SendContend(Incode.IncodeFirstCommand(TYPE, byt));//获取查询排行的命令
     //Debug.Log("发送排行榜命令");
 }
Beispiel #7
0
        public override void DoCommand()                  //世界排行榜    还有一个没做
        {
            List <PersonalInfo> rank = SqlConn.GetRank(); //直接向数据库查询 获取排行榜

            conn.SendBts(Incode.IncodeFirstCommand(type, DataDo.Object2Json(rank)));
        }
Beispiel #8
0
 public byte[] MyIncode()
 {
     return(Incode.IncodeFirstCommand(type, DataDo.Object2Json <LoginInfo>(info)));
 }