コード例 #1
0
        public async Task <PhotoListResponse> ReceiveMessageAsync()
        {
            // All photos are from the same user
            var username = await _networkCommunication.ReceiveStringAsync();

            // Receive array of photos
            var photos = new List <Photo>();
            var count  = await _networkCommunication.ReceiveIntAsync();

            for (var i = 0; i < count; i++)
            {
                var name = await _networkCommunication.ReceiveStringAsync();

                var file = await _fileCommunication.ReceiveFileAsync();

                photos.Add(new Photo
                {
                    Name     = name,
                    File     = file,
                    Username = username
                });
            }

            return(new PhotoListResponse(username, photos));
        }
コード例 #2
0
        public async Task <CommentListResponse> ReceiveMessageAsync()
        {
            // All comments are from the same photo
            var username = await _networkCommunication.ReceiveStringAsync();

            var photoName = await _networkCommunication.ReceiveStringAsync();

            // Receive array of comments
            var comments = new List <Comment>();
            var count    = await _networkCommunication.ReceiveIntAsync();

            for (var i = 0; i < count; i++)
            {
                var text = await _networkCommunication.ReceiveStringAsync();

                comments.Add(new Comment
                {
                    Username  = username,
                    PhotoName = photoName,
                    Text      = text
                });
            }

            return(new CommentListResponse(username, photoName, comments));
        }
コード例 #3
0
        public async Task <CommentListRequest> ReceiveMessageAsync()
        {
            var username = await _networkCommunication.ReceiveStringAsync();

            var photoName = await _networkCommunication.ReceiveStringAsync();

            return(new CommentListRequest(username, photoName));
        }
コード例 #4
0
        public async Task <CreateUserRequest> ReceiveMessageAsync()
        {
            string userName = await _networkStream.ReceiveStringAsync();

            string password = await _networkStream.ReceiveStringAsync();

            return(new CreateUserRequest(userName, password));
        }
コード例 #5
0
        public async Task <CommentPhotoRequest> ReceiveMessageAsync()
        {
            var namePhoto = await _networkCommunication.ReceiveStringAsync();

            var userName = await _networkCommunication.ReceiveStringAsync();

            var text = await _networkCommunication.ReceiveStringAsync();

            return(new CommentPhotoRequest(namePhoto, userName, text));
        }
コード例 #6
0
        public async Task <ErrorResponse> ReceiveMessageAsync()
        {
            var errorId = await _networkCommunication.ReceiveShortAsync();

            var message = await _networkCommunication.ReceiveStringAsync();

            return(new ErrorResponse((ErrorId)errorId, message));
        }
コード例 #7
0
        public async Task <CreatePhotoRequest> ReceiveMessageAsync()
        {
            var name = await _networkCommunication.ReceiveStringAsync();

            var filePath = await _fileCommunication.ReceiveFileAsync();

            return(new CreatePhotoRequest(name, filePath));
        }
コード例 #8
0
        public async Task <UserListResponse> ReceiveMessageAsync()
        {
            // Receive array of photos
            var users = new List <User>();
            var count = await _networkCommunication.ReceiveIntAsync();

            for (var i = 0; i < count; i++)
            {
                var userName = await _networkCommunication.ReceiveStringAsync();

                users.Add(new User
                {
                    Username = userName,
                    Password = "******"
                });
            }

            return(new UserListResponse(users));
        }