Exemple #1
0
        void HandleNewServerConnected(Connection connection)
        {
            IDomainOfInterest       doi = null;
            IDomainOfResponsibility dor = null;
            Guid syncID = Guid.Empty;

            AttemptedConnections.Add(connection);

            connection["serverSync.getDoR"]().OnSuccess <string>(delegate(string serializedDoR)
            {
                dor = StringSerialization.DeserializeObject <IDomainOfResponsibility>(serializedDoR);
                if (doi != null && syncID != Guid.Empty)
                {
                    AddRemoteServer(connection, dor, doi, syncID);
                }
            }).OnError(m => { Console.WriteLine("Could not retrieve DoR of remote server, reason: " + m); });

            connection["serverSync.getDoI"]().OnSuccess <string>(delegate(string serializedDoI)
            {
                doi = StringSerialization.DeserializeObject <IDomainOfInterest>(serializedDoI);
                if (dor != null && syncID != Guid.Empty)
                {
                    AddRemoteServer(connection, dor, doi, syncID);
                }
            }).OnError(m => { Console.WriteLine("Could not retrieve DoI of remote server, reason: " + m); });;

            connection["serverSync.getSyncID"]().OnSuccess <string>(delegate(string remoteSyncID)
            {
                syncID = new Guid(remoteSyncID);
                if (dor != null && doi != null)
                {
                    AddRemoteServer(connection, dor, doi, syncID);
                }
            }).OnError(m => { Console.WriteLine("Could not retrieve SyncID of remote server, reason: " + m); });;
        }
Exemple #2
0
        void HandleNewServerConnected(Connection connection)
        {
            IDomainOfInterest       doi = null;
            IDomainOfResponsibility dor = null;
            Guid syncID = Guid.Empty;

            connection["serverSync.getDoR"]().OnSuccess <string>(delegate(string serializedDoR) {
                dor = StringSerialization.DeserializeObject <IDomainOfResponsibility>(serializedDoR);
                if (doi != null && syncID != Guid.Empty)
                {
                    AddRemoteServer(connection, dor, doi, syncID);
                }
            });

            connection["serverSync.getDoI"]().OnSuccess <string>(delegate(string serializedDoI)
            {
                doi = StringSerialization.DeserializeObject <IDomainOfInterest>(serializedDoI);
                if (dor != null && syncID != Guid.Empty)
                {
                    AddRemoteServer(connection, dor, doi, syncID);
                }
            });

            connection["serverSync.getSyncID"]().OnSuccess <Guid>(delegate(Guid remoteSyncID)
            {
                syncID = remoteSyncID;
                if (dor != null && doi != null)
                {
                    AddRemoteServer(connection, dor, doi, remoteSyncID);
                }
            });
        }
Exemple #3
0
        /// <summary>
        /// Updates domain-of-responsibility on the remote server associated with a given connection.
        /// </summary>
        /// <param name="connection">Connection to the remote server.</param>
        /// <param name="serializedDoR">New serialized domain-of-responsibility.</param>
        internal void HandleRemoteDoRChanged(Connection connection, string serializedDoR)
        {
            foreach (var server in ServerSync.RemoteServers)
            {
                if (server.Connection == connection)
                {
                    var newDoR = StringSerialization.DeserializeObject <IDomainOfResponsibility>(serializedDoR);
                    (server as RemoteServerImpl).DoR = newDoR;
                    return;
                }
            }

            throw new Exception("Received a DoR update for an unregistered server");
        }