Example #1
0
        private void GotFullChunks(MessageType messageType, TcpClient client, List <byte[]> receivedChunks)
        {
            //1. Client send Login Try
            //2. Client asks for a groups
            //3. Client asks for a tests
            //4. Client send result
            switch (messageType)
            {
            case MessageType.ClientLoginTry:
            {
                var val = receivedChunks.CombineChunksInto <User>();
                LogTry?.Invoke(val, client);
                break;
            }

            case MessageType.ClientRequestGroups:
            {
                var val = receivedChunks.CombineChunksInto <User>();
                GetGroups?.Invoke(val, client);
                break;
            }

            case MessageType.ClientRequestTests:
            {
                //Group id
                var val = receivedChunks.CombineChunksInto <int>();
                GetTests?.Invoke(val, client);
                break;
            }

            case MessageType.ClientSendResult:
            {
                var val = receivedChunks.CombineChunksInto <Result>();
                ResultSend?.Invoke(val, client);
                break;
            }
            }
        }
Example #2
0
        async Task <IEnumerable <Test> > IRequestHandler <GetTests, IEnumerable <Test> > .Handle(GetTests request, CancellationToken cancellationToken)
        {
            var @event = await this.eventsRepository.GetById(request.EventId, cancellationToken);

            if (@event == null)
            {
                throw new Exception("cannot find event");
            }
            return(@event.Tests.OrderBy(a => a.Ordinal));
        }