public void Start()
        {
            _id   = _coordinator.GenerateNodeId();
            _info = new NodeRemoteInfo(_id, InternalNet.Endpoint, ExternalNet.Endpoint);
            Log   = LogManager.GetLogger(ToString());

            _coordinator.OnClusterViewChanged.Subscribe(ClusterViewChanged);
            _coordinator.JoinWith(this);

            ExternalNet.Start();
            InternalNet.Start();
        }
        public async Task <S2SPeer> GetNodePeer(ulong nodeId)
        {
            NodeRemoteInfo info = ClusterView.GetNode(nodeId);

            if (info.LocalConnectionId.HasValue)
            {
                return(InternalNet.GetPeer(info.LocalConnectionId.Value));
            }
            else
            {
                var peer = (S2SPeer)await InternalNet.Connect(info.InternalEndpoint);

                info.LocalConnectionId = peer.Channel.Id;
                return(peer);
            }
        }
 public override void Deserialize(BinaryReader reader)
 {
     base.Deserialize(reader);
     Info = NodeRemoteInfoSerializer.Deserialize(reader);
 }
 public static void Serialize(NodeRemoteInfo obj, BinaryWriter writer)
 {
     writer.Write(obj.NodeId);
     writer.Write(obj.InternalAddress);
     writer.Write(obj.ExternalAddress);
 }
 public override void Deserialize(BinaryReader reader)
 {
     base.Deserialize(reader);
     Info = NodeRemoteInfoSerializer.Deserialize(reader);
 }
 public static void Serialize(NodeRemoteInfo obj, BinaryWriter writer)
 {
     writer.Write(obj.NodeId);
     writer.Write(obj.InternalAddress);
     writer.Write(obj.ExternalAddress);
 }
 public async Task <IServerPeer> ConnectToServer(string serverEndPoint)
 {
     return((IServerPeer) await Connect(NodeRemoteInfo.ParseIPEndPoint(serverEndPoint)).ConfigureAwait(false));
 }