예제 #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); });;
        }
예제 #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);
                }
            });
        }
예제 #3
0
        internal void HandleLocalDoIChanged(object sender, EventArgs e)
        {
            string serializedDoI = StringSerialization.SerializeObject <IDomainOfInterest>(ServerSync.LocalServer.DoI);

            foreach (var server in ServerSync.RemoteServers)
            {
                server.Connection["serverSync.updateDoI"](serializedDoI);
            }
        }
예제 #4
0
        internal void HandleLocalDoRChanged(object sender, EventArgs e)
        {
            string serializedDoR = StringSerialization.SerializeObject <IDomainOfResponsibility>(
                ServerSync.LocalServer.DoR);

            foreach (var server in ServerSync.RemoteServers)
            {
                server.Connection["serverSync.updateDoR"](serializedDoR);
            }
        }
예제 #5
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");
        }
예제 #6
0
 /// <summary>
 /// Returns serialized DoR for this server.
 /// </summary>
 /// <returns>Serialized DoR.</returns>
 string GetDoR()
 {
     return(StringSerialization.SerializeObject <IDomainOfResponsibility>(ServerSync.LocalServer.DoR));
 }
예제 #7
0
 /// <summary>
 /// Returns serialized DoI for this server.
 /// </summary>
 /// <returns>Serialized DoI.</returns>
 string GetDoI()
 {
     return(StringSerialization.SerializeObject <IDomainOfInterest>(ServerSync.LocalServer.DoI));
 }