void _client_FileRequestResponseReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileRequestResponseEventArgs e)
        {
            if (e.File.Hash != File.Hash) return;

            if (e.File == File)
            {
                if (e.Response == FileRequestMode.Available)
                {
                    if (_state == FileState.Requesting)
                    {
                        StateEnum = FileState.DownloadConfirmed;
                    }
                }
                else
                {
                    MessageBox.Show("Unable to retrieve file. It may have been removed, or is locked by its owner or the server.");
                }
            }
        }
 void server_MessageReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.MessageEventArgs e)
 {
     _serverMessage = e.Message;
     if (_serverMessage is FileModificationMessage)
     {
         _serverModificationMessage = _serverMessage as FileModificationMessage;
     }
 }
 void client_FullFileListReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileListEventArgs e)
 {
     Log("Server file list received");
 }
 void server_ClientIdentified(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.IdentificationEventArgs e)
 {
     Log(string.Format("Client {0} returned identification from {1} ({2})", e.Client.PublicName, e.Client.IPAddress, e.Client.InstanceId));
 }
 void server_LostConnection(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.ExceptionEventArgs e)
 {
     Log(string.Format("Connection Lost: {0}", e.ThrownException.Message));
 }
        void _client_FileTransferProgressed(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileTransferEventArgs e)
        {
            if (e.FileChunk.Header.Hash != File.Hash) return;

            StateEnum = FileState.Downloading;

            _percent = Math.Round((double) ((e.FileChunk.ChunkIndex + 1) * 100) / e.FileChunk.Header.ChunkCount, 2);
        }
Exemple #7
0
 static void _server_LostConnection(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.ExceptionEventArgs e)
 {
     throw new NotImplementedException();
 }
 protected override void OnMessageReceived(ObviousCode.Interlace.BitTunnelLibrary.Interfaces.IMessage message)
 {
 }
        void _client_FileListUpdateReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileListModificationEventArgs e)
        {
            foreach (FileModificationDescriptor file in e.Modifications)
            {
                if (file.OriginId != _client.ConnectionDetails.InstanceId) continue;

                if (file.Mode == FileModificationMode.New)
                {
                    if (file.OriginId != _client.ConnectionDetails.InstanceId) continue;

                    SetFileAsAvailable(file.Hash);
                }
                else if (file.Mode == FileModificationMode.Renamed)
                {
                    RenameFile(file.ToFileDescriptor());
                }
            }
        }
 void client_FileTransferFailed(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileDescriptorEventArgs e)
 {
     Log(string.Format("File {0} ({1}) transfer failed", e.File.FileName, e.File.Hash));
 }
 void client_FileTransferInitiated(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileTransferEventArgs e)
 {
     Log(string.Format("File ({0}) transfer initiated", e.FileChunk.Header.Hash));
 }
 void client_FileTransferCompleted(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileTransferCompletedEventArgs e)
 {
     Log(string.Format("File ({0}) transfer completed", e.Hash));
 }
 void client_FileRequestResponseReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileRequestResponseEventArgs e)
 {
     Log(string.Format("File {0} ({1}) request response received : {2}", e.File.FileName, e.File.Hash, e.Response));
 }
 void client_FileListUpdateReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileListModificationEventArgs e)
 {
     Log("Server file update received");
 }
        void _client_FileTransferCompleted(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileTransferCompletedEventArgs e)
        {
            if (e.Hash != File.Hash) return;

            StateEnum = FileState.Downloaded;

            string destination = Path.Combine(_client.Settings.TransferPath.FullName, File.FileName);

            int token = 1;

            while (System.IO.File.Exists(destination))
            {
                destination = string.Format("{0} ({1})", Path.Combine(_client.Settings.TransferPath.FullName, File.FileName), ++token);
            }

            try
            {
                if (System.IO.File.Exists(e.Location))
                {
                    System.IO.File.Move(e.Location, destination);
                }
            }
            catch(Exception ex)
            {

            }
        }
 void client_FullFileListReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileListEventArgs e)
 {
     _fileListReceived = true;
 }
        void _client_FileTransferFailed(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileDescriptorEventArgs e)
        {
            if (e.File.Hash != File.Hash) return;

            MessageBox.Show(string.Format("File transfer of {0} failed", e.File.FileName));
            StateEnum = FileState.Failed;
        }
 void _server_ClientIdentified(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.IdentificationEventArgs e)
 {
     _clientDetails[e.Client.InstanceId] = e.Client;
 }
Exemple #19
0
 static void _localClient_LostConnection(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.ExceptionEventArgs e)
 {
     Console.WriteLine("Client Lost Connection: {0}", e.ThrownException.Message);
     _forceQuit = true;
 }
 private void PrepareForBuild(ObviousCode.Interlace.BitTunnelLibrary.Messages.FileChunkMessage chunk)
 {
     //possibly have a small metadata file to describe what files are what in case of a crash - allow for restart.
     //Requires File Descriptor to be added to file chunk message header - not sure if I want to do that
 }
 void server_AvailableFilesUpdated(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileListModificationEventArgs e)
 {
     foreach (FileModificationDescriptor modification in e.Modifications)
     {
         FileDescriptor file = modification.ToFileDescriptor();
         Log(string.Format("The file \"{0}\" ({1}) on client {2} was {3}", file.FileName, file.Hash, modification.OriginId, modification.Mode == FileModificationMode.New ? "Added" : "Removed"));
     }
 }
 //Maybe consider a Connection Changed event
 void Client_LostConnection(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.ExceptionEventArgs e)
 {
     EnableRefresh(false);
 }
 void server_FileRequested(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileRequestEventArgs e)
 {
     Log(string.Format("File {0} requested ({1})", e.File.FileName, e.File.Hash));
 }
 void _client_FileListUpdateReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileListModificationEventArgs e)
 {
     foreach (FileModificationDescriptor modification in e.Modifications)
     {
         if (modification.Mode == FileModificationMode.New)
         {
             AddFileToFileList(modification.ToFileDescriptor());
         }
         else if (modification.Mode == FileModificationMode.Renamed)
         {
             RenameFile(modification.ToFileDescriptor());
         }
         else
         {
             Invoke((MethodInvoker)delegate
             {
                 _helper.RemoveFileFromListView(modification.Hash);
             });
         }
     }
 }
 void server_MessageReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.MessageEventArgs e)
 {
     Log(string.Format("{0} Message received", e.Message.Key));
 }
 void _client_FullFileListReceived(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileListEventArgs e)
 {
     ReloadFullFileList(e.FileList);
 }
 public void HandleRequest(ObviousCode.Interlace.ChatroomServer.Protocols.ChatroomServerProtocol protocol, PropertyDictionary request)
 {
     protocol.Parent.NotifyOnLogout(protocol);
 }
 void client_FileTransferProgressed(object sender, ObviousCode.Interlace.BitTunnelLibrary.Events.FileTransferEventArgs e)
 {
     Log(string.Format("File ({0}) chunk {1} of {2} received", e.FileChunk.Header.Hash, e.FileChunk.Header.ChunkIndex, e.FileChunk.Header.ChunkCount));
 }