コード例 #1
0
        public void Connect(string clientId, string password)
        {
            // try
            // {
            Player userVar = (from user in ctx.Players
                              where (user.PlayerId == clientId)
                              select user).FirstOrDefault <Player>();

            if (userVar != null)
            {
                if (userVar.Password == password)
                {
                    if (clients.ContainsKey(clientId))
                    {
                        UserAlreadyConnectedFault fault = new UserAlreadyConnectedFault()
                        {
                            Message = "UserId: " + clientId + " alraedy connected!!"
                        };
                        throw new FaultException <UserAlreadyConnectedFault>(fault);
                    }

                    IFourInRowCallback callback =
                        OperationContext.Current.GetCallbackChannel <IFourInRowCallback>();
                    clients.Add(clientId, callback);
                    Thread updateThread = new Thread(UpdateClientsLists);
                    updateThread.Start();
                }
                else
                {
                    UserPasswordFault passwordFault = new UserPasswordFault()
                    {
                        Message = "Error: the password isn't correct, try again!."
                    };
                    throw new FaultException <UserPasswordFault>(passwordFault);
                }
            }
            else
            {
                UserIdNotExistFault fault = new UserIdNotExistFault()
                {
                    Message = "Error: check your user Id ,The user Id \"" + clientId + "\" doesn't exist"
                };
                throw new FaultException <UserIdNotExistFault>(fault);
            }
        }
コード例 #2
0
ファイル: FourInRowService.cs プロジェクト: noorb404/ForInRow
        public bool LogIn(string username, string pssword)
        {
            var s = (from u in dc.Customers
                     where u.UserName == username &&
                     u.Password == pssword
                     select u).FirstOrDefault <Customer>();

            if (s == null)
            {
                return(false);
            }
            IFourInRowCallback callback =
                OperationContext.Current.GetCallbackChannel <IFourInRowCallback>();

            clients.Add(s.FirstName, callback);
            s.IsOnline = 1;
            Thread update = new Thread(updateClients);

            update.Start();
            return(true);
        }