protected void DoBeat() { while (true) { Thread.Sleep(HEARTBEAT_PERIOD); HashSet <string> nodes = new HashSet <string>(View.Nodes); foreach (var node in nodes) { try { RemotingEndpoint remotingEndpoint = GetRemoteEndpoint(node); BeatDelegate beatDelegate = remotingEndpoint.Beat; beatDelegate.BeginInvoke(EndpointURL, asyncResult => { AsyncResult ar = (AsyncResult)asyncResult; BeatDelegate remoteDel = (BeatDelegate)ar.AsyncDelegate; remoteDel.EndInvoke(asyncResult); }, null); } catch (RemotingException) { // do nothing } } } }
public static RemotingEndpoint GetRemoteEndpoint(string url) { RemotingEndpoint remote = (RemotingEndpoint)Activator.GetObject( typeof(RemotingEndpoint), url); return(remote); }
private View DoGetView(string remotingEndpointUrl) { RemotingEndpoint remotingEndpoint = GetRemoteEndpoint(remotingEndpointUrl); GetViewDelegate getViewDelegate = remotingEndpoint.GetView; var asyncResult = getViewDelegate.BeginInvoke(null, null); return(getViewDelegate.EndInvoke(asyncResult)); }
private HashSet <string> DoJoinView(string remotingEndpointUrl, HashSet <string> view) { RemotingEndpoint remotingEndpoint = GetRemoteEndpoint(remotingEndpointUrl); JoinViewDelegate joinViewDelegate = remotingEndpoint.JoinView; var asyncResult = joinViewDelegate.BeginInvoke(view, null, null); return(joinViewDelegate.EndInvoke(asyncResult)); }
public Message SendMessageToRemote(RemotingEndpoint remotingEndpoint, Message message) { try { RemoteAsyncDelegate remoteDel = new RemoteAsyncDelegate(remotingEndpoint.OnReceiveMessage); IAsyncResult ar = remoteDel.BeginInvoke(message, null, null); //ar.AsyncWaitHandle.WaitOne(); // This should not be necessary, since EndInvoke already waits for completion // unless we want to provide a timeout a do something with it return(remoteDel.EndInvoke(ar)); } catch (Exception e) { Log("Server at " + remotingEndpoint.EndpointURL + " is unreachable. (For more detail: " + e.Message + ")"); throw new SocketException(); } }
public Message SendMessageToRemoteURL(string remoteURL, Message message) { RemotingEndpoint remotingEndpoint = GetRemoteEndpoint(remoteURL); return(SendMessageToRemote(remotingEndpoint, message)); }