Exemplo n.º 1
0
 public void ClientEndpointManager(ClientEndpoint message)
 {
     DownloadSocket.Connect(message.ClientEndPoint);
     DownloadSocket.Send(serializer.Serialize(new ClientIDMessage(ClientIP, ClientID)));
     DownloadSocket.Send(serializer.Serialize(new FileDownloadRequest(ClientIP, message.FileName, ClientID)));
 }
Exemplo n.º 2
0
        /// <inheritdoc />
        public async Task <IClientObservable> CreateObservable()
        {
            var proxy = await ClientEndpoint.Create(grainFactory);

            return(new ClientObservable(proxy));
        }
Exemplo n.º 3
0
        public bool Pump()
        {
            List <MockStack> serverStacks;

            if (Queue.Count == 0)
            {
                return(false);
            }

            MockQueueItem item = Queue.Peek();

            switch (item.ItemType)
            {
            //  state #1 - client requested a send of a request
            case MockQueueItem.QueueType.ClientSendRequest:
                Queue.Dequeue();
                if (item.Request.Destination == null)
                {
                    item.Request.Destination = ServerAddress;
                }
                ClientStack.SendRequest(item.Request);
                break;

            //  state #2 - client ready for network send
            case MockQueueItem.QueueType.ClientSendRequestNetwork:
                Queue.Dequeue();
                MessageEncoder encoder        = new Spec.MessageEncoder18();
                byte[]         encodedRequest = encoder.Encode(item.Request);
                EndPoint       destination    = item.Request.Destination;

                item             = new MockQueueItem(MockQueueItem.QueueType.ServerSendRequestNetwork, encodedRequest);
                item.Source      = ClientAddress;
                item.Destination = destination;
                Queue.Enqueue(item);
                break;

            //  state #3 - server receives network send
            case MockQueueItem.QueueType.ServerSendRequestNetwork:
                Queue.Dequeue();
                serverStacks = ServerStacks[item.Destination];
                foreach (MockStack s in serverStacks)
                {
                    s.MyEndPoint.ReceiveData(item);
                }

                break;

            //  state #4 - server application receives request
            case MockQueueItem.QueueType.ServerSendRequest:
                break;


            // state #5 - server sends an response
            case MockQueueItem.QueueType.ServerSendResponse:
                Queue.Dequeue();
                serverStacks = ServerStacks[item.Source];
                Assert.AreEqual(1, serverStacks.Count);
                foreach (MockStack s in serverStacks)
                {
                    s.SendResponse(item.Exchange, item.Response);
                }
                break;

            // state #6 - server ready to send over network
            case MockQueueItem.QueueType.ServerSendResponseNetwork:
                Queue.Dequeue();
                encoder = new Spec.MessageEncoder18();
                byte[] encodedResponse = encoder.Encode(item.Response);

                MockQueueItem item2 = new MockQueueItem(MockQueueItem.QueueType.ClientSendResponseNetwork, encodedResponse);
                item2.Source      = item.Response.Source;
                item2.Destination = item.Destination;
                Queue.Enqueue(item2);
                break;

            // state #7 - client receives response over network
            case MockQueueItem.QueueType.ClientSendResponseNetwork:
                Queue.Dequeue();

                ClientEndpoint.ReceiveData(item);

                break;

            // state #8 - client application to process response
            case MockQueueItem.QueueType.ClientSendResponse:
                break;
            }

            return(Queue.Count > 0);
        }