/// <summary> /// We are sender. /// </summary> /// <param name="remote"></param> /// <param name="data"></param> /// <param name="filename"></param> public FileTransfer(Contact remote, Stream data, string filename) : base(remote.P2PVersionSupported, remote, remote.SelectBestEndPointId()) { _context = new FTContext(filename, (ulong)data.Length); _dataStream = data; _sending = true; }
/// <summary> /// We are receiver. /// </summary> /// <param name="p2pSession"></param> public FileTransfer(P2PSession p2pSession) : base(p2pSession) { _context = new FTContext(Convert.FromBase64String(p2pSession.Invitation.BodyValues["Context"].Value)); _sending = false; _dataStream = null; // Must be set when InvitationReceived }
public override bool ValidateInvitation(SLPMessage invite) { bool ret = base.ValidateInvitation(invite); try { FTContext context = new FTContext(Convert.FromBase64String(invite.BodyValues["Context"].Value)); Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, String.Format("{0} ({1} bytes) (base validate {2})", context.Filename, context.FileSize, ret), GetType().Name); return(ret && (!string.IsNullOrEmpty(context.Filename)) && (context.FileSize > 0)); } catch (Exception) { // We can't parse the context, so refuse the invite Trace.WriteLineIf(Settings.TraceSwitch.TraceError, String.Format("Unable to parse file transfer invite: {0}", invite.ToDebugString()), GetType().Name); return(false); } }
public override bool ValidateInvitation(SLPMessage invite) { bool ret = base.ValidateInvitation(invite); try { FTContext context = new FTContext(Convert.FromBase64String(invite.BodyValues["Context"].Value)); Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, String.Format("{0} ({1} bytes) (base validate {2})", context.Filename, context.FileSize, ret), GetType().Name); return ret && (!string.IsNullOrEmpty(context.Filename)) && (context.FileSize > 0); } catch (Exception) { // We can't parse the context, so refuse the invite Trace.WriteLineIf(Settings.TraceSwitch.TraceError, String.Format("Unable to parse file transfer invite: {0}", invite.ToDebugString()), GetType().Name); return false; } }