view topology/HostMessage.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 976d43003487
children
line wrap: on
line source

using System;
using System.Net;
using MessagePack;

namespace Christie_net.topology{
    [MessagePackObject]
    public class HostMessage { 
        [Key("hostName")]
        private String hostName = "";
        [Key("port")]
        private int port ;
        [Key("nodeName")]
        private String nodeName; // this is nodeName which have these IP and port.
        [Key("connectionName")]
        private String connectionName;
        [Key("remoteNodeName")]
        private String remoteNodeName;
        [Key("cookie")]
        private String cookie; // MD5
        [Key("alive")]
        private Boolean alive;

    public HostMessage() {}
    
    public void setHostAndPort(HostMessage hostMessage) {
        setHostAndPort(hostMessage.getHostName(), hostMessage.getPort());
    }

    public void setHostAndPort(String hostName, int port) {
        this.hostName = hostName;
        this.port = port;
    }

    public void setNodeInfo(String nodeName, String connectionName, String remoteNodeName){
        this.nodeName = nodeName;
        this.connectionName = connectionName;
        this.remoteNodeName = remoteNodeName;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    public String getHostName() { return hostName; }

    public int getPort() { return port; }

    public String getNodeName() { return nodeName; }

    public String getConnectionName() { return connectionName; }

    public String getRemoteNodeName() { return remoteNodeName; }

    public void setAlive(Boolean alive) { this.alive = alive; }

    public Boolean isAlive() { return alive; }

    public void setCookie(String cookie) { this.cookie = cookie; }

    public String getCookie() { return cookie; }

    public String toString() {
        return "HostMessage : name = " + hostName + ", port = " + Convert.ToInt32(port) + " connectionName = " +
                connectionName + " nodeName = " + nodeName + " remoteNodeName = " + remoteNodeName
                + " cokkie = " + cookie ;
    }

    }
}