Exemplo n.º 1
0
 public void InitiateDialog(ProtocolDialogData data)
 {
     SendBytes(new[] { data.Version });
     SendBytes(new[] { (byte)data.FileAction });
     SendBytes(new[] { (byte)data.FileType });
     SendBytes(BitConverter.GetBytes(data.RelativeFilePath.Length));
     SendBytes(Encoding.GetEncoding("UTF-8").GetBytes(data.RelativeFilePath));
 }
Exemplo n.º 2
0
        public ProtocolDialogData AcceptDialog()
        {
            var version      = ReadValue(1, value => value[0]);
            var fileAction   = ReadValue(1, value => (FileAction)value[0]);
            var fileType     = ReadValue(1, value => (FileType)value[0]);
            var filePathSize = ReadValue(4, value => BitConverter.ToInt32(value, 0));
            var relativePath = ReadValue(filePathSize, value => Encoding.GetEncoding("UTF-8").GetString(value));

            _dialogData = new ProtocolDialogData
            {
                Version          = version,
                FileAction       = fileAction,
                RelativeFilePath = relativePath,
                FileType         = fileType
            };

            return(_dialogData);
        }