view topology/manager/CheckComingHost.cs @ 71:1169915705ab default tip

fix TopologyNode connect
author KaitoMaeshiro <aosskaito@cr.ie.u-ryukyu.ac.jp>
date Sun, 06 Feb 2022 16:47:41 +0900
parents 1a42115e51bb
children
line wrap: on
line source

using System;
using System.Collections.Generic;
using Christie_net.annotation;
using Christie_net.codegear;

namespace Christie_net.topology.manager
{
    public class CheckComingHost : CodeGear
    {
        [Take] public HostMessage hostMessage;
        [Peek] public Dictionary<String, String> absCookieTable;

        public CheckComingHost()
        {
        }

        public override void Run(CodeGearManager cgm)
        {

            String cookie = hostMessage.getCookie();
            // check cookie
            if (cookie != null)
            {
                if (absCookieTable.ContainsKey(cookie))
                {
                    hostMessage.setNodeName(cookie);
                    Console.WriteLine("match");
                    // coming host has ever joined this App
                    GetLocalDgm().Put("reconnectHost", hostMessage);
                    cgm.Setup(new SearchHostName());
                }
            }
            else
            {
                Console.WriteLine("put new host " + hostMessage.getHostName());
                GetLocalDgm().Put("orderHash", "order");
                GetLocalDgm().Put("newHost", hostMessage);
            }

            cgm.Setup(new CheckComingHost());
        }
    }
}