Example #1
0
        public override void ClientSide(FormCollection OpenWindows, CreateClientWindow CreateWindow, Common.Connections.Connection ThisConnection)
        {
            Form FoundWindow = null;
            IRecentConversationsWindow ConvWindow = null;

            //LOOP THROUGH EACH OPEN WINDOW LOOKING FOR THE CONV WINDOW
            foreach (Form tmpWindow in OpenWindows)
            {
                try
                {
                    ConvWindow = (IRecentConversationsWindow)tmpWindow;
                    break;
                }
                catch
                {
                }
            }

            //IF WE DIDNT FIND THE CONVERSATION LIST WINDOW THEN CREATE A NEW ONE
            if (ConvWindow == null)
            {
                CreateWindow(null, null, ref FoundWindow, WindowType.RecentConversationList);
            }

            //INVOKE THE CHANGING OF THE DATASOURCE ON THE WINDOW
            FoundWindow.Invoke((MethodInvoker) delegate
            {
                ConvWindow            = (IRecentConversationsWindow)FoundWindow;
                ConvWindow.RecentList = this.RecentList;
            });
        }
        public override void ServerSide(List <Common.Connections.Connection> ServerConnections, Common.Connections.Connection ThisConnection)
        {
            DBAccess.ConversationDataContext ConversationList = new Common.DBAccess.ConversationDataContext();
            ConversationItem tmpConversation = new ConversationItem();

            //SETUP THE CONVERSTAION FOR THE DATABASE
            tmpConversation.DateCreated      = DateTime.Now;
            tmpConversation.ConversationGUID = this.ConversationID;

            //ADD ALL THE MEMBERS TO THE CONVERSATION VIA LINQ
            tmpConversation.ConversationMembers.AddRange((from a in this.ConversationMembers.Distinct() select new ConversationMember {
                UserID = a
            }));

            //ADD THE CONVERSATION ITEM TO THE DB CONNECTION AND UPDATE IT
            ConversationList.ConversationItems.InsertOnSubmit(tmpConversation);
            ConversationList.SubmitChanges();

            //SEND THIS MESSAGE BACK TO THE CLIENT SO THEY WILL CREATE A CONVERSATION WINDOW
            Send(ThisConnection);
        }
Example #3
0
 public override void ServerSide(List <Common.Connections.Connection> ServerConnections, Common.Connections.Connection ThisConnection)
 {
     throw new NotImplementedException();
 }
Example #4
0
        public override void ServerSide(List <Common.Connections.Connection> ServerConnections, Common.Connections.Connection ThisConnection)
        {
            IAuthenticationProvider AuthProvider = StaticFunctions.GetAuthenticationProvider();

            //GET THE AUTHENTICATION RESULT FROM THE AUTHENTICATE FUNCTION
            AuthResult tmpResult = AuthProvider.Authenticate(UserName, Password);

            //DOUBLE CHECK TO MAKE SURE THAT THE USERID WE GOT BACK IS NOT ALREADY IN USE
            if ((from a in ServerConnections where a.UserID == tmpResult.UserID && a != ThisConnection select a).Count() != 0)
            {
                //THROW AN ERROR BECAUSE A USER CAN NOT BE LOGGED IN TWICE
                new Message_Error()
                {
                    Message = "Username cannot be logged in twice!"
                }.Send(ThisConnection);
                tmpResult.Success = false;

                //CLOSE THE CONNECTION SO THE USER MAY LOGIN THE NEXT TIME
                //TODO: SHOULD PROVIDE THIS CONNECTION A METHOD OF SAYING NOT TO LOG THEM OFF OR ATLEAST LETTING THEM KNOW WHY THEY ARE BEING LOGGED OFF
                (from a in ServerConnections where a.UserID == tmpResult.UserID && a != ThisConnection select a).First().TcpConnection.Close();
            }

            //STORE THE RESULT FROM THE AUTHENTICATION CALL
            if (tmpResult.Success)
            {
                ThisConnection.UserID        = tmpResult.UserID;
                ThisConnection.Authenticated = true;
                this.Success     = tmpResult.Success;
                this.UserID      = tmpResult.UserID;
                this.DisplayName = tmpResult.DisplayName;
            }

            //SEND THE RESPONSE BACK TO THE CLIENT
            Send(ThisConnection);
        }