Esempio n. 1
0
 private void OnMessageReceivedFromMulticastGroup(object sender, MessegeReceviedEventArgs args)
 {
     if (args.Payload.MessageTypeName == typeof(DiscoveryRequestMessage).Name)
     {
         _discoveryRequestMessage = (DiscoveryRequestMessage)args.Payload;
         _serverNode.GetDataQuantity();
     }
     if (args.Payload.MessageTypeName == typeof(ConnectTheGraphMessage).Name)
     {
         _serverNode.ConnectoToKnowServers();
         Console.WriteLine("Server graph connected !");
     }
 }
        private void OnMessageReceived(object sender, MessegeReceviedEventArgs args)
        {
            if (args.Payload.MessageTypeName == typeof(SubscribeSuccessMessage).Name)
            {
                _isDiscoveryResponseBussSubsciribed = true;
                while (_discoveryMessagesQueue.Count > 0)
                {
                    var message = _discoveryMessagesQueue.Dequeue();
                    SendDicoveryRequest(message);
                }
            }

            if (args.Payload.MessageTypeName == typeof(DiscoveryResponseMessage).Name)
            {
                var payload = (DiscoveryResponseMessage)args.Payload;
                Console.WriteLine($"{payload.NodIpEndPoint} : {payload.DataQuantity}");
                ServerDiscovered?.Invoke(this,
                                         new ServerDiscoveredEventArgs(payload.NodIpEndPoint, payload.DataQuantity));
            }
        }