Beispiel #1
0
        private TcpSocketConnectCallback OnConnected(TrackerGetHttpEntry entry)
        {
            return(connected =>
            {
                if (connected.Status == SocketStatus.OK)
                {
                    Action callback = () =>
                    {
                        context.CallConnected(entry.Address, entry.Request.Hash);
                    };

                    entry.Status = TrackerGetHttpStatus.Connected;
                    context.Queue.Add(callback);
                }
            });
        }
Beispiel #2
0
        private void HandleConnectionResponse(IPEndPoint endpoint, TrackerGetUdpEntry entry, byte[] data)
        {
            if (data.Length < 16)
            {
                context.CallPacketIgnored(endpoint, data.Length);
                return;
            }

            if (Bytes.Equals(TrackerGetUdpProtocol.Connect, data, 0, 4) == false)
            {
                context.CallPacketIgnored(endpoint, data.Length);
                return;
            }

            entry.Connection = Bytes.Copy(data, 8, 8);
            entry.Status     = TrackerGetUdpStatus.Connected;

            context.CallConnected(entry.Address, entry.Request.Hash, entry.Transaction, entry.Connection);
        }