Example #1
0
 // ============================================
 // PUBLIC Methods
 // ============================================
 /// Get Command Manager Instance
 public static CmdManager GetInstance()
 {
     if (manager == null)
     {
         manager = new CmdManager();
     }
     return(manager);
 }
        // ============================================
        // PUBLIC Constructors
        // ============================================
        public NetworkManager(MenuManager menu, UserPanel userPanel, NotebookViewer nv)
        {
            this.userPanel = userPanel;
            this.notebookViewer = nv;
            this.menuManager = menu;

            // Initialize P2PManager & CMD Manager
            this.p2pManager = P2PManager.GetInstance();
            this.cmdManager = CmdManager.GetInstance();

            // Network
            SetSensitiveNetworkMenu(P2PManager.IsListening());

            // Add Event Handlers
            this.menuManager.Activated += new EventHandler(OnMenuActivated);
            notebookViewer.NetworkViewer.ItemRemoved += new PeerSelectedHandler(OnPeerRemove);
        }
Example #3
0
            private void SendProtocolEvent(XmlRequest xmlRequest)
            {
                switch (xmlRequest.FirstTag)
                {
                case "login":
                    Login login = new Login(peer, xmlRequest);
                    if (login.Authentication() == true && login.User != null)
                    {
                        // Add to Known User
                        P2PManager.AddPeer(login.User, peer);

                        // Start Login Event
                        CmdManager.LoginEvent(peer, login.User);
                    }
                    else
                    {
                        Debug.Log("Auth Failed: {0}", peer.GetRemoteIP());
                    }
                    break;

                case "quit":
                    CmdManager.QuitEvent(peer, xmlRequest);
                    break;

                case "error":
                    CmdManager.ErrorEvent(peer, xmlRequest);
                    break;

                case "get":
                    CmdManager.GetEvent(peer, xmlRequest);
                    break;

                case "ask":
                    CmdManager.AskEvent(peer, xmlRequest);
                    break;

                case "snd":
                    CmdManager.SndEvent(peer, xmlRequest);
                    break;

                case "snd-start":
                    CmdManager.SndStartEvent(peer, xmlRequest);
                    break;

                case "snd-end":
                    CmdManager.SndEndEvent(peer, xmlRequest);
                    break;

                case "snd-abort":
                    CmdManager.SndAbortEvent(peer, xmlRequest);
                    break;

                case "recv-abort":
                    CmdManager.RecvAbortEvent(peer, xmlRequest);
                    break;

                default:
                    CmdManager.UnknownEvent(peer, xmlRequest);
                    break;
                }
            }
Example #4
0
        private void ParseCommand(string xml)
        {
#if DEBUG
            Debug.Log("==================================================");
            if (peer.Info != null)
            {
                UserInfo userInfo = this.peer.Info as UserInfo;
                Debug.Log("Response From: {0}", userInfo.Name);
            }
            else
            {
                Debug.Log("Response From: {0}", peer.GetRemoteIP());
            }
            Debug.Log("Response: '{0}'", xml);
            Debug.Log("==================================================");
#endif

            // Parse Xml Command
            XmlRequest xmlRequest = null;
            try {
                xmlRequest = new XmlRequest(xml);
                xmlRequest.Parse();
            } catch (Exception e) {
                Debug.Log("Parse Xml: {0}", e.Message);
                return;
            }

            // Protocol Commands
            switch (xmlRequest.FirstTag)
            {
            case "login":
                Login login = new Login(peer, xmlRequest);
                if (login.Authentication() == true && login.User != null)
                {
                    // Add to Known User
                    P2PManager.AddPeer(login.User, peer);

                    // Start Login Event
                    CmdManager.StartLoginEvent(peer, login.User);
                }
                else
                {
                    Debug.Log("Auth Failed: {0}", peer.GetRemoteIP());
                }
                break;

            case "quit":
                CmdManager.StartQuitEvent(peer, xmlRequest);
                break;

            case "error":
                CmdManager.StartErrorEvent(peer, xmlRequest);
                break;

            case "get":
                CmdManager.StartGetEvent(peer, xmlRequest);
                break;

            case "ask":
                CmdManager.StartAskEvent(peer, xmlRequest);
                break;

            case "accept":
                CmdManager.StartAcceptEvent(peer, xmlRequest);
                break;

            case "snd":
                CmdManager.StartSndEvent(peer, xmlRequest);
                break;

            case "snd-start":
                CmdManager.StartSndStartEvent(peer, xmlRequest);
                break;

            case "snd-end":
                CmdManager.StartSndEndEvent(peer, xmlRequest);
                break;

            case "snd-abort":
                CmdManager.StartSndAbortEvent(peer, xmlRequest);
                break;

            case "recv-abort":
                CmdManager.StartRecvAbortEvent(peer, xmlRequest);
                break;

            default:
                CmdManager.StartUnknownEvent(peer, xmlRequest);
                break;
            }
        }
Example #5
0
        protected void OnAddProtocolCmd(P2PManager p2p, CmdManager cmd)
        {
            // Initalize Talk Manager
            TalkManager.Initialize(this.nyFolder);

            // Add Protocol Event Handler
            CmdManager.UnknownEvent += new ProtocolHandler(OnUnknownEvent);

            // Sensitivize Talk Menu
            SetSensitiveTalkMenu(true);
        }
Example #6
0
        protected void OnDelProtocolCmd(P2PManager p2p, CmdManager cmd)
        {
            // Uninitalize Talk Manager
            TalkManager.Uninitialize();

            // Del Protocol Event Handler
            CmdManager.UnknownEvent -= new ProtocolHandler(OnUnknownEvent);

            // Sensitivize Talk Menu
            SetSensitiveTalkMenu(false);
        }
        private void OnDelProtocolEvent(P2PManager p2p, CmdManager cmd)
        {
            // NetworkViewer
            NetworkViewer networkViewer = notebookViewer.NetworkViewer;
            networkViewer.SendFile -= new SendFileHandler(OnSendFile);

            // Folder Viewers
            notebookViewer.SaveFile -= new SendFileHandler(OnSaveFile);
            notebookViewer.FileSend -= new FileSendEventHandler(OnSendFileMenu);
            notebookViewer.FolderRefresh -= new StringEventHandler(OnFolderRefresh);

            // Protocol Commands
            CmdManager.GetEvent -= new ProtocolHandler(OnGetEvent);
            CmdManager.AskEvent -= new ProtocolHandler(OnAskEvent);
            CmdManager.AcceptEvent -= new ProtocolHandler(OnAcceptEvent);
            CmdManager.SndEvent -= new ProtocolHandler(OnSndEvent);
            CmdManager.SndStartEvent -= new ProtocolHandler(OnSndStartEvent);
            CmdManager.SndEndEvent -= new ProtocolHandler(OnSndEndEvent);
            CmdManager.SndAbortEvent -= new ProtocolHandler(OnSndAbortEvent);
            CmdManager.RecvAbortEvent -= new ProtocolHandler(OnRecvAbortEvent);
        }
 protected void OnDelProtocolCmd(P2PManager p2p, CmdManager cmd)
 {
     CmdManager.LoginEvent -= new ProtocolLoginHandler(OnPeerLogin);
     CmdManager.GetEvent -= new ProtocolHandler(OnGetEvent);
     CmdManager.UnknownEvent -= new ProtocolHandler(OnUnknownEvent);
 }