Exemple #1
0
        void mainView_MainCloseEvent()
        {
            if(currentState is StateIdle)
                fileListManager.SaveFileList();

            StopPeerConnectionManager();

            if (currentState is StateIdle)
            {
                AState lastState = currentState;
                currentState = currentState.MoveState();
                if (currentState != lastState)
                {
                    currentState.OpenConversationEvent+=new OpenConversationDelegate(currentState_OpenConversationEvent);
                }
                lastState = null;
            }

            EmptyCurrentStateOutputBuffer();

            inputMessageQueue.Clear();

            ProcessOutputQueue();

            toBreak = true;

            mainLoopStarted = false;
        }
Exemple #2
0
        private void ProcessInputQueue()
        {
            while (inputMessageQueue.Count > 0)
            {
                Common.Protocol.Message firstMessage = inputMessageQueue.Dequeue();
                AState lastState = currentState;

                mainView.LoginEvent -= this.mainView_LoginEvent;

                currentState = currentState.AnalyzeMessage(firstMessage);
                if (currentState != lastState)
                {
                    currentState.OpenConversationEvent+=new OpenConversationDelegate(currentState_OpenConversationEvent);
                }
                lastState = null;
                if (currentState is StateIdle)
                {
                    ((StateIdle)currentState).UserName = this.currentUserName;
                    ((StateIdle)currentState).Ip = this.localIpAddress;
                    ((StateIdle)currentState).Port = this.localPort;
                }
                if (currentState.ToCloseConnection)
                {
                    toBreak = true;
                }
                if (currentState.Disconected)
                {
                    StopPeerConnectionManager();
                    mainView.Initialise();
                    DisposeFileTransferView();
                }
                mainView.LoginEvent += this.mainView_LoginEvent;
            }
            EmptyCurrentStateOutputBuffer();
        }
Exemple #3
0
        void mainView_LogoutEvent()
        {
            fileListManager.SaveFileList();

            StopPeerConnectionManager();

            foreach (KeyValuePair<string,IConversationController> pair in conversationControllers)
            {
                pair.Value.CloseView();
            }
            conversationControllers.Clear();

            this.mainView.LoginEvent -= mainView_LoginEvent;

            currentState = currentState.MoveState();

            this.mainView.LoginEvent += mainView_LoginEvent;

            EmptyCurrentStateOutputBuffer();

            inputMessageQueue.Clear();

            ProcessOutputQueue();

            toBreak = true;

            mainLoopStarted = false;

            mainView.Initialise();

            if(fileTransferView!=null)
                fileTransferView.CloseView();

            fileTransferView = null;
        }
Exemple #4
0
        private void HandleSocketException()
        {
            ErrorHandler.HandleError("The connection with the server has been lost!", "Connection Error", (IWin32Window)mainView);

            toBreak = true;
            mainLoopStarted = false;

            StopPeerConnectionManager();

            mainView.LoginEvent -= this.mainView_LoginEvent;
            this.currentState = new StateInitial();

            currentState.MainView = mainView;
            currentState.OpenConversationEvent += new OpenConversationDelegate(currentState_OpenConversationEvent);

            foreach (KeyValuePair<string,IConversationController> controller in conversationControllers)
            {
                controller.Value.CloseView();
            }
            conversationControllers.Clear();
            if (fileListView != null)
            {
                fileListView.CloseView();
            }

            if (fileTransferView != null)
            {
                fileTransferView.CloseView();
            }

            currentState.ConversationControllers = conversationControllers;

            mainView.LoginEvent += new LoginEventHandler(this.mainView_LoginEvent);

            mainView.Initialise();
        }
Exemple #5
0
 void createAccountView_CloseAccountViewEvent()
 {
     this.createAccountView.CloseView();
     this.mainView.ShowView();
     currentState = currentState.MoveState();
     if (currentState is StateIdle)
     {
         ((StateIdle)currentState).PeerConnectionManager = peerConnectionManager;
     }
 }
Exemple #6
0
 public void InitialiseCreateAccount(ICreateAccountView newCreateAccountView)
 {
     this.createAccountView = newCreateAccountView;
     currentState.CreateAccountView = newCreateAccountView;
     AState lastState = currentState;
     currentState = currentState.MoveState();
     if (currentState != lastState)
     {
         currentState.OpenConversationEvent+=new OpenConversationDelegate(currentState_OpenConversationEvent);
     }
     lastState = null;
     this.createAccountView.Initialise();
     this.createAccountView.CloseAccountViewEvent += new CloseAccountViewEventHandler(createAccountView_CloseAccountViewEvent);
     this.createAccountView.CreateAccountEvent += new CreateAccountEventHandler(createAccountView_CreateAccountEvent);
     this.createAccountView.ShowView();
 }
Exemple #7
0
        /// <summary>
        /// This is called from the main class.
        /// </summary>
        public void Initialise(IMainView mainView)
        {
            this.currentState = new StateInitial();

            currentState.MainView = mainView;
            currentState.OpenConversationEvent += new OpenConversationDelegate(currentState_OpenConversationEvent);

            this.mainView = mainView;
            this.mainView.AddContactEvent += new AddContactEventHandler(mainView_AddContactEvent);
            this.mainView.AddGroupEvent += new AddGroupEventHandler(mainView_AddGroupEvent);
            this.mainView.ChangeContactGroupEvent += new ChangeContactGroupEventHandler(mainView_ChangeContactGroupEvent);
            this.mainView.ChangeStatusEvent += new ChangeStatusEventHandler(mainView_ChangeStatusEvent);
            this.mainView.LoginEvent += new LoginEventHandler(mainView_LoginEvent);
            this.mainView.LogoutEvent += new LogoutEventHandler(mainView_LogoutEvent);
            this.mainView.MainCloseEvent += new MainCloseEventHandler(mainView_MainCloseEvent);
            this.mainView.OpenConversationEvent += new OpenConversationEventHandler(mainView_OpenConversationEvent);
            this.mainView.OpenFileTransferViewEvent += new OpenFileTransferViewEventHandler(mainView_OpenFileTransferViewEvent);
            this.mainView.RemoveContactEvent += new RemoveContactEventHandler(mainView_RemoveContactEvent);
            this.mainView.OpenSignUpViewEvent += new OpenSignUpViewHandler(mainView_OpenSignUpViewEvent);
            this.mainView.OpenArchiveViewEvent += new OpenArchiveViewHandler(mainView_OpenArchiveViewEvent);
            this.mainView.ChangeSettingsEvent += new ChangeSettings(mainView_ChangeSettingsEvent);
            this.mainView.RemoveGroupEvent += new RemoveGroupEventHandler(mainView_RemoveGroupEvent);
            this.mainView.OpenFileListViewEvent += new OpenFileListViewHandler(mainView_OpenFileListViewEvent);
            this.mainView.Initialise();

            this.conversationControllers = new Dictionary<string, IConversationController>();
            this.inputMessageQueue = new Queue<Common.Protocol.Message>();
            this.outputMessageQueue = new Queue<Common.Protocol.Message>();

            currentState.ConversationControllers = conversationControllers;
        }