Ejemplo n.º 1
0
        private void autodiscovery_OnDataReceived(object sender, SocketDataEventArgs e)
        {
            // check that we actually want this message type on this interface
            if (e.Type == PacketType.BroadcastUDP)
            {
                // TODO :: add logging
                // deserialise the data
                AutoDiscoveryMessage msg = AutoDiscoveryMessageSerialiser.Deserialise(e.Data);
                if (_autoDiscoverySocket.BroadcastSourceAddress.Equals(msg.Ip.Address))
                {
                    return;
                }
                switch (msg.MessageType)
                {
                case BroadcastMessageType.Startup:
                    Console.WriteLine("Autodiscovery: Client start up -> {0}", msg.Ip.Address);
                    _autoDiscoveryList.Add(msg.Ip.Address);
                    NodeStartup(new IPEndPoint(msg.Ip.Address, InternodePort));
                    break;

                case BroadcastMessageType.Shutdown:
                    Console.WriteLine("Autodiscovery: Client shutdown -> {0}", msg.Ip.Address);
                    _autoDiscoveryList.Remove(msg.Ip.Address);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private void internode_OnDataReceived(object sender, SocketDataEventArgs e)
        {
            InterNodeCommunicationMessage msg = InterNodeCommunicationMessageSerialiser.Deserialise(e.Data);

            Console.WriteLine("INCM :: " + msg.MessageType.ToString());
            switch (msg.MessageType)
            {
            case InterNodeMessageType.AddToCache:
                // typeof ClientResultMessage
                AddToCache(msg.IsLocalOnly, msg.Tag, msg.Data);
                break;

            case InterNodeMessageType.AddToQueue:
                // typeof ClientMessage
                AddToQueue(msg.IsLocalOnly, msg.Data);
                break;

            case InterNodeMessageType.RemoveFromCache:
                RemoveFromCache(msg.IsLocalOnly, msg.Tag);
                break;

            case InterNodeMessageType.RemoveFromQueue:
                RemoveFromQueue(msg.IsLocalOnly, msg.Tag);
                break;

            case InterNodeMessageType.NewNodeDiscovered:
                NewNodeDiscoveredOnNetwork(e.Source);
                break;

            case InterNodeMessageType.ChangeMessageStateInQueue:
                // typeof QueuedProcessState
                QueueMessageStateChanged(msg.Tag, msg.Data);
                break;

            case InterNodeMessageType.FullCacheUpdateSent:
                SendFullCacheUpdate(e.Source);
                break;

            case InterNodeMessageType.FullQueueUpdateSent:
                SendFullQueueUpdate(e.Source);
                break;

            case InterNodeMessageType.FullCacheUpdateReceived:
                UpdateCacheWithFullUpdate(msg.Data);
                GetDataFromNode(e.Source, InterNodeMessageType.FullQueueUpdateSent);
                break;

            case InterNodeMessageType.FullQueueUpdateReceived:
                UpdateQueueWithFullUpdate(msg.Data);
                break;

            case InterNodeMessageType.StartUp:
                GetDataFromNode(e.Source, InterNodeMessageType.FullCacheUpdateSent);
                break;

            default:
                Console.WriteLine("Internode message received. Default.");
                break;
            }
        }
Ejemplo n.º 3
0
 private void Server_TCPReceiveData(object sender, SocketDataEventArgs e)
 {
     if (e.Data != null && e.Data.Length > 0)
     {
         dataHelper.Enqueue(e.Data, e.ConnId, e.EndPoint.ToString().Split(':')[0], Convert.ToInt32(e.EndPoint.ToString().Split(':')[1]));
         Invoke(new MethodInvoker(() =>
         {
             richTextRebackMsg.AppendText("接收时间:" + DateTime.Now + "\n");
             richTextRebackMsg.AppendText("数据:" + e.Data.ToNumberArrayString(" ", 16) + "\n");
         }));
         if (saveDataToLog)
         {
             log.Info(e.Data.ToNumberArrayString(" ", 16));
         }
     }
 }
Ejemplo n.º 4
0
        private void OnSourceSocketDataIncoming(object sender, SocketDataEventArgs e)
        {
            if (!(sender is NodeSocket sink) || sink.IO != NodeSocketIO.Sink || sink.Input == null)
            {
                return;
            }

            if (sink == _a)
            {
                _s1.Value = (double)e.Data;
            }

            if (sink == _b)
            {
                _s2.Value = (double)e.Data;
            }
        }
Ejemplo n.º 5
0
        private void client_OnDataReceived(object sender, SocketDataEventArgs e)
        {
            ClientMessage msg = ClientMessageSerialiser.Deserialise(e.Data);

            switch (msg.MessageType)
            {
            case ClientMessageType.FetchResult:
                GetResultFromCache(e.Source, msg.Tag);
                break;

            case ClientMessageType.NewTask:
                StartNewTask(e.Source, msg.Data, msg.Tag);
                break;

            case ClientMessageType.TimeoutPrevention:
                // we are preventing a timeout from taking place here, no action is neccessary
                break;
            }
        }
Ejemplo n.º 6
0
 private void OnSourceSocketDataOutgoingEvent(object sender, SocketDataEventArgs e)
 {
     _value.Text = e.Data.ToString();
 }