Exemplo n.º 1
0
 void MessagingSocket_Inquired_PutRequest(object sender, InquiredEventArgs e)
 {
     PutRequest putReq = (PutRequest)e.InquireMessage;
     LocalPut (putReq.Key, putReq.LifeTime, putReq.Value, e.EndPoint);
     _sock.StartResponse (e, new PutResponse ());
 }
Exemplo n.º 2
0
 void MessagingSocket_Inquired_GetRequest(object sender, InquiredEventArgs e)
 {
     GetRequest getReq = (GetRequest)e.InquireMessage;
     _sock.StartResponse (e, new GetResponse (_lht.Get (getReq.Key, getReq.TypeID, _mergerMap[getReq.TypeID])));
 }
Exemplo n.º 3
0
        void MessagingSocket_Inquired_CloseNodeQuery(object sender, InquiredEventArgs e)
        {
            if (!_active)
                return;

            CloseNodeQuery req = (CloseNodeQuery)e.InquireMessage;
            NodeHandle[] closeNodes = _algo.GetCloseNodes (req.Destination, req.NumberOfCloseNodes, req.Sender);
            _sock.StartResponse (e, new CloseNodeResponse (_selfId, _tcpPort, closeNodes));
            _algo.Touch (new NodeHandle (req.Sender, e.EndPoint, req.SenderTcpPort));
        }
Exemplo n.º 4
0
        void MessagingSocket_Inquired_NextHopQuery(object sender, InquiredEventArgs e)
        {
            if (!_active)
                return;

            NextHopQuery req = (NextHopQuery)e.InquireMessage;
            NodeHandle[] nextHops = _algo.GetNextHopNodes (req.Destination, Math.Max (_maxNodeHandlesPerResponse, req.NumberOfNextHops), req.Sender);
            bool isRoot = false;
            if (nextHops == null) {
                isRoot = true;
                nextHops = _algo.GetCloseNodes (req.Destination, req.NumberOfRootCandidates, req.Sender);
            }
            _sock.StartResponse (e, new NextHopResponse (_selfId, _tcpPort, isRoot, nextHops));
            _algo.Touch (new NodeHandle (req.Sender, e.EndPoint, req.SenderTcpPort));
        }
Exemplo n.º 5
0
        void Messaging_Inquired(object sender, InquiredEventArgs e)
        {
            Message msg = e.InquireMessage as Message;
            _sock.StartResponse (e, "ACK");
            _router.RoutingAlgorithm.Touch (new NodeHandle (msg.Sender, e.EndPoint, msg.SenderTcpPort));

            for (int i = 0; i < msg.Entries.Length; i ++) {
                DHTEntry entry = msg.Entries[i];
                IPutterEndPointStore epStore = entry.Value as IPutterEndPointStore;
                if (epStore != null && epStore.EndPoint == null)
                    epStore.EndPoint = e.EndPoint;
                _dht.LocalPut (entry.Key, entry.LifeTime, entry.Value);
            }
        }