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); });; }
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); } }); }
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); } }
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); } }
/// <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"); }
/// <summary> /// Returns serialized DoR for this server. /// </summary> /// <returns>Serialized DoR.</returns> string GetDoR() { return(StringSerialization.SerializeObject <IDomainOfResponsibility>(ServerSync.LocalServer.DoR)); }
/// <summary> /// Returns serialized DoI for this server. /// </summary> /// <returns>Serialized DoI.</returns> string GetDoI() { return(StringSerialization.SerializeObject <IDomainOfInterest>(ServerSync.LocalServer.DoI)); }