public object SendMulticastMessage(List <Server> destinations, Message message) { if (this._shardChannels != null && _shardChannels.Count > 0) { IDictionary responses = new HashVector <Server, object>(); IDictionary delegates = new HashVector <Server, MessageDelegate>(); IDictionary results = new HashVector <Server, IAsyncResult>(); IEnumerator channelsEnumerator = destinations.GetEnumerator(); while (channelsEnumerator.MoveNext()) { Server destination = (Server)channelsEnumerator.Current; if (this._shardChannels[destination] != null) { MessageDelegate msgDelegate = new MessageDelegate(SendUnicastMessage); delegates.Add(destination, msgDelegate); IAsyncResult ar = msgDelegate.BeginInvoke(destination, message, null, null); results.Add(destination, ar); } } IEnumerator delegatesEnumerator = results.GetEnumerator(); while (delegatesEnumerator.MoveNext()) { DictionaryEntry pair = (DictionaryEntry)delegatesEnumerator.Current; Object ret = ((MessageDelegate)delegates[pair.Key]).EndInvoke((IAsyncResult)results[pair.Key]); if (ret != null) { responses.Add(pair.Key, ret); } } return(responses); } throw new ClusterException(ErrorCodes.Cluster.SERVER_NOT_EXIST); }
public object SendBroadcastMessage(Message message) { if (this._shardChannels != null && _shardChannels.Count > 0) { IDictionary responses = new HashVector <Server, Object>(); IDictionary delegates = new HashVector <Server, MessageDelegate>(); IDictionary results = new HashVector <Server, IAsyncResult>(); IEnumerator channelsEnumerator = _shardChannels.GetEnumerator(); while (channelsEnumerator.MoveNext()) { KeyValuePair <Server, IDualChannel> pair = (KeyValuePair <Server, IDualChannel>)channelsEnumerator.Current; MessageDelegate msgDelegate = new MessageDelegate(SendUnicastMessage); delegates.Add(pair.Key, msgDelegate); IAsyncResult ar = msgDelegate.BeginInvoke(pair.Key, message, null, null); results.Add(pair.Key, ar); } IEnumerator delegatesEnumerator = results.GetEnumerator(); while (delegatesEnumerator.MoveNext()) { DictionaryEntry pair = (DictionaryEntry)delegatesEnumerator.Current; Object ret = ((MessageDelegate)delegates[pair.Key]).EndInvoke(((IAsyncResult)pair.Value)); if (ret != null) { responses.Add(pair.Key, ret); } } return(responses); } throw new ClusterException(ErrorCodes.Cluster.SERVER_NOT_EXIST); }