You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Network/FileTransfer/FileReceiver.cs

40 lines
1.6 KiB

6 years ago
using System;
using ZeroLevel.Models;
6 years ago
6 years ago
namespace ZeroLevel.Network.FileTransfer
6 years ago
{
public sealed class FileReceiver
6 years ago
{
private readonly string _baseFolder;
private readonly ClientFolderNameMapper _nameMapper;
private readonly FileWriter _receiver;
6 years ago
public FileReceiver(IRouter router, string baseFolder, ClientFolderNameMapper nameMapper)
6 years ago
{
_baseFolder = baseFolder ?? throw new Exception(nameof(baseFolder));
_nameMapper = nameMapper ?? throw new Exception(nameof(nameMapper));
_receiver = new FileWriter(baseFolder);
6 years ago
if (false == router.ContainsRequestorInbox("__file_transfer_start_transfer__"))
6 years ago
{
router.RegisterInbox<FileStartFrame, InvokeResult>("__file_transfer_start_transfer__",
(c, f) => _receiver.Incoming(f, nameMapper(c)));
6 years ago
}
if (false == router.ContainsRequestorInbox("__file_transfer_frame__"))
6 years ago
{
router.RegisterInbox<FileFrame, InvokeResult>("__file_transfer_frame__",
(_, f) => _receiver.Incoming(f));
6 years ago
}
if (false == router.ContainsRequestorInbox("__file_transfer_complete_transfer__"))
6 years ago
{
router.RegisterInbox<FileEndFrame, InvokeResult>("__file_transfer_complete_transfer__",
(_, f) => _receiver.Incoming(f));
6 years ago
}
if (false == router.ContainsRequestorInbox("__file_transfer_ping__"))
6 years ago
{
router.RegisterInbox<bool>("__file_transfer_ping__", (_) => true);
6 years ago
}
}
}
}

Powered by TurnKey Linux.