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

36 lines
1.5 KiB

6 years ago
using System;
5 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>("__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>("__file_transfer_frame__", (_, f) => _receiver.Incoming(f));
6 years ago
}
if (false == router.ContainsRequestorInbox("__file_transfer_complete_transfer__"))
6 years ago
{
router.RegisterInbox<FileEndFrame>("__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.