public abstract Task <bool> HandleMessage(BaseWebSocketConnection connetction, IncomingMessage message);
Beispiel #2
0
 public override Task HandleMessage(AlphaWebSocketConnection connection, IncomingMessage message)
 {
     Context.QuantumHandler.HandleAsync(message.Envelope);
     return(Task.CompletedTask);
 }
Beispiel #3
0
 public override async Task HandleMessage(AuditorWebSocketConnection connection, IncomingMessage message)
 {
     //send message back. The message contains handshake data
     await connection.SendMessage(message.Envelope.Message);
 }
Beispiel #4
0
        public override async Task HandleMessage(AuditorWebSocketConnection connection, IncomingMessage message)
        {
            var quantumHandler   = (AuditorQuantumHandler)connection.Context.QuantumHandler;
            var quantaBatch      = (QuantaBatch)message.Envelope.Message;
            var quanta           = quantaBatch.Quanta;
            var quantaBatchCount = quanta.Count;

            for (var i = 0; i < quantaBatchCount; i++)
            {
                var quantumEnvelope = quanta[i];
                var quantum         = (Quantum)quantumEnvelope.Message;
                if (quantum.Apex <= quantumHandler.LastAddedQuantumApex)
                {
                    continue;
                }

                if (quantum.Apex != quantumHandler.LastAddedQuantumApex + 1)
                {
                    logger.Warn($"Batch has invalid quantum apexes (current: {quantumHandler.LastAddedQuantumApex}, received: {quantum.Apex}). New apex cursor request will be send.");
                    await connection.SendMessage(new SetApexCursor { Apex = quantumHandler.LastAddedQuantumApex });

                    return;
                }
                _ = Context.QuantumHandler.HandleAsync(quantumEnvelope);
            }
        }