Exemple #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="rootElement">Root Element from Sharing Stage</param>
 public SyncRoot(ObjectElement rootElement)
 {
     Element   = rootElement;
     FieldName = Element.GetName().GetString();
     InitializeSyncSettings();
     InitializeDataModel();
 }
Exemple #2
0
        public XToolsApp(string[] args = null)
        {
            parsedArguments = ParseCommandLine(args);
            this.logWriter = new ConsoleLogWriter();

            ClientConfig config = new ClientConfig(ClientRole.Primary);
            config.SetServerAddress(GetArgumentOrDefault("sessionserver", "localhost"));
            config.SetLogWriter(this.logWriter);

            this.Manager = SharingManager.Create(config);
            this.syncListener = new ConsoleSyncReporter();

            this.viewerConnection = this.Manager.GetPairedConnection();
            this.serverConnection = this.Manager.GetServerConnection();
            this.SessionManager = this.Manager.GetSessionManager();

            BeginPairing();

            ViewerListener = new NetworkConnectionAdapter();
            ViewerListener.ConnectedCallback += this.OnViewerConnected;
            ViewerListener.ConnectionFailedCallback += this.OnViewerConnectionFailed;
            ViewerListener.DisconnectedCallback += this.OnViewerDisconnected;
            viewerConnection.AddListener((byte)MessageID.StatusOnly, ViewerListener);

            ServerListener = new NetworkConnectionAdapter();
            ServerListener.ConnectedCallback += this.OnSessionConnected;
            ServerListener.ConnectionFailedCallback += this.OnSessionConnectionFailed;
            ServerListener.DisconnectedCallback += this.OnSessionDisconnected;
            serverConnection.AddListener((byte)MessageID.StatusOnly, ServerListener);

            this.rootObject = this.Manager.GetRootSyncObject();
            this.rootObject.AddListener(this.syncListener);

            // Listen for new sessions
            SessionManagerListener = new XToolsSessionManagerListener();
            this.SessionManager.AddListener(SessionManagerListener);
        }
Exemple #3
0
        public void Connect(string server, string userName = "******", int port = 20602, ClientRole clientRole = ClientRole.Primary)
        {
            ClientConfig config = new ClientConfig(clientRole);
            config.SetServerAddress(server);
            config.SetServerPort(port);
            config.SetLogWriter(LogWriter);

            this.SharingManager = SharingManager.Create(config);
            this.SharingManager.SetUserName(userName);
            
            this.viewerConnection = this.SharingManager.GetPairedConnection();
            this.serverConnection = this.SharingManager.GetServerConnection();
            this.SessionManager = this.SharingManager.GetSessionManager();
            
            BeginPairing();

            ViewerListener = new NetworkConnectionAdapter();
            ViewerListener.ConnectedCallback += this.OnViewerConnected;
            ViewerListener.ConnectionFailedCallback += this.OnViewerConnectionFailed;
            ViewerListener.DisconnectedCallback += this.OnViewerDisconnected;
            viewerConnection.AddListener((byte)MessageID.StatusOnly, ViewerListener);

            ServerListener = new NetworkConnectionAdapter();
            ServerListener.ConnectedCallback += this.OnSessionConnected;
            ServerListener.ConnectionFailedCallback += this.OnSessionConnectionFailed;
            ServerListener.DisconnectedCallback += this.OnSessionDisconnected;
            serverConnection.AddListener((byte)MessageID.StatusOnly, ServerListener);

            this.syncListener = new ConsoleSyncReporter();
            this.rootObject = this.SharingManager.GetRootSyncObject();
            this.rootObject.AddListener(this.syncListener);

            SessionManagerListener = new XToolsSessionManagerListener(this.LogWriter);
            this.SessionManager.AddListener(SessionManagerListener);
            networkMessageLoop = new Timer(new TimerCallback((a) => Update()), null, 0, 1000);
        }
Exemple #4
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>True</c> to release both managed and unmanaged resources; <c>False</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    if (this.syncListener != null)
                    {
                        this.syncListener.Dispose();
                        this.syncListener = null;
                    }

                    if (this.viewerConnection != null)
                    {
                        this.viewerConnection.Dispose();
                        this.viewerConnection = null;
                    }

                    if (this.serverConnection != null)
                    {
                        this.serverConnection.Dispose();
                        this.serverConnection = null;
                    }

                    if (this.rootObject != null)
                    {
                        this.rootObject.Dispose();
                        this.rootObject = null;
                    }

                    if (this.SessionManager != null)
                    {
                        this.SessionManager.Dispose();
                        this.SessionManager = null;
                    }

                    if (this.Manager != null)
                    {
                        this.Manager.Dispose();
                        this.Manager = null;
                    }
                }

                this.disposed = true;
            }
        }
Exemple #5
0
        private void CleanupNetworkObjects()
        {
            if (networkMessageLoop != null)
            {
                networkMessageLoop.Dispose();
                networkMessageLoop = null;
            }

            if (this.rootObject != null)
            {
                this.rootObject.RemoveListener(this.syncListener);
                this.rootObject.Dispose();
                this.rootObject = null;
            }

            if (this.syncListener != null)
            {
                this.syncListener.Dispose();
                this.syncListener = null;
            }

            if (viewerConnection != null)
            {
                viewerConnection.RemoveListener((byte)MessageID.StatusOnly, ViewerListener);
                viewerConnection.Disconnect();
                this.viewerConnection.Dispose();
                this.viewerConnection = null;
            }

            if (serverConnection != null)
            {
                serverConnection.RemoveListener((byte)MessageID.StatusOnly, ServerListener);
                serverConnection.Disconnect();
                this.serverConnection.Dispose();
                this.serverConnection = null;
            }

            if (this.SessionManager != null)
            {
                this.SessionManager.RemoveListener(this.SessionManagerListener);
                this.SessionManager.Dispose();
                this.SessionManager = null;
            }

            if (this.SessionManagerListener != null)
            {
                this.SessionManagerListener.Dispose();
                this.SessionManagerListener = null;
            }

            if (SharingManager != null)
            {
                SharingManager.Dispose();
                SharingManager = null;
            }
        }