private void OnReceiveCompleted(object sender, System.Net.Sockets.SocketAsyncEventArgs e) { try { System.IO.MemoryStream stream = new System.IO.MemoryStream(e.Buffer, 0, e.BytesTransferred); BrodcastMessage msg = stream.Deserialize <BrodcastMessage>(e.BytesTransferred); if (msg.MessageType == "SMART_ROUTE") { if (!msg.Token.VerifyMd5Hash(msg.NodeID + mTokenKey)) { return; } if (msg.NodeID != NodeID && msg.Cluster == this.Cluster) { Loger.Process(LogType.BROAD_DEBUG, "broadcast reveive {0}", msg); if (string.IsNullOrEmpty(msg.IP)) { msg.IP = ((IPEndPoint)e.RemoteEndPoint).Address.ToString(); } try { if (!mDiscoverTable.ContainsKey(msg.NodeID)) { DiscoverEventArgs de = new DiscoverEventArgs(); de.Address = msg.IP; de.Port = int.Parse(msg.Port); de.NodeID = msg.NodeID; mDiscoverTable[msg.NodeID] = de; OnDiscorver(de); } } catch (Exception e__) { Loger.Process(LogType.BROAD_ERROR, "node ping error {0}", e__.Message); } } } } catch (Exception e_) { Loger.Process(LogType.BROAD_ERROR, "broadcast reveive error {0}", e_.Message); } finally { OnReceive(); } }