コード例 #1
0
        /// <summary>
        /// Called when a PUP comes in on a known socket.  Establishes a new BSP channel.
        /// A worker of the appropriate type is woken up to service the channel.
        /// </summary>
        /// <param name="p"></param>
        public static void EstablishRendezvous(PUP p, Type workerType)
        {
            if (p.Type != PupType.RFC)
            {
                Log.Write(LogType.Error, LogComponent.RTP, "Expected RFC pup, got {0}", p.Type);
                return;
            }

            UInt32 socketID = SocketIDGenerator.GetNextSocketID();

            Log.Write(LogType.Error, LogComponent.Exp, "setting up rendezvous on {0} {1} with socketID {2}", p.DestinationPort, p.SourcePort, socketID);

            BSPChannel newChannel = new BSPChannel(p, socketID);

            newChannel.OnDestroy += OnChannelDestroyed;
            _activeChannels.Add(socketID, newChannel);

            //
            // Initialize the worker for this channel.
            InitializeWorkerForChannel(newChannel, workerType);

            // Send RFC response to complete the rendezvous:

            // Modify the destination port to specify our network
            PUPPort sourcePort = p.DestinationPort;

            sourcePort.Network = DirectoryServices.Instance.LocalNetwork;
            PUP rfcResponse = new PUP(PupType.RFC, p.ID, newChannel.ClientPort, sourcePort, newChannel.ServerPort.ToArray());

            Log.Write(LogComponent.RTP,
                      "Establishing Rendezvous, ID {0}, Server port {1}, Client port {2}.",
                      p.ID, newChannel.ServerPort, newChannel.ClientPort);

            Router.Instance.SendPup(rfcResponse);
        }
コード例 #2
0
ファイル: EFTPManager.cs プロジェクト: shirriff/IFS
        public static void SendFile(PUPPort destination, Stream data)
        {
            UInt32      socketID   = SocketIDGenerator.GetNextSocketID();
            EFTPChannel newChannel = new EFTPChannel(destination, socketID);

            _activeChannels.Add(socketID, newChannel);

            EFTPSend.StartSend(newChannel, data);
        }