コード例 #1
0
        /// <summary>
        /// Constructs a new info.
        /// </summary>
        /// <param name="channel">The tcp channel to bind.</param>
        internal static MeshMember Create(IPEndPoint endpoint, Connection channel)
        {
            var node = new MeshMember();

            node.LastTouchUtc = DateTime.UtcNow;
            node.Identifier   = endpoint.ToIdentifier();
            node.EndPoint     = endpoint;
            return(node);
        }
コード例 #2
0
        /// <summary>
        /// Constructs a new info node for oneself.
        /// </summary>
        internal static MeshMember Create()
        {
            var node = new MeshMember();

            node.LastTouchUtc = DateTime.UtcNow;
            node.Identifier   = Service.Mesh.Identifier;
            node.EndPoint     = Service.Mesh.BroadcastEndpoint;

            // Also add to the membership
            Service.Registry.GetMembership().Add(Service.Mesh.BroadcastEndpoint.ToString(), new GossipMember(node.EndPoint));
            return(node);
        }
コード例 #3
0
ファイル: MeshHandler.cs プロジェクト: toomasz/emitter
        /// <summary>
        /// Handles the command.
        /// </summary>
        /// <param name="channel">The channel sending the command.</param>
        /// <param name="command">The command received.</param>
        private static void OnHandshakeAck(Connection channel, MeshEvent command)
        {
            // Attempt to register
            MeshMember node;
            IPEndPoint ep;

            if (!MeshMember.TryParseEndpoint(command.Value, out ep))
            {
                Service.Logger.Log(LogLevel.Error, "Unable to parse endpoint: " + command.Value);
                channel.Close();
                return;
            }

            // Register the endpoint
            if (Service.Mesh.Members.TryRegister(ep, channel, out node))
            {
                // Send an event since we're connected to the node
                Service.InvokeNodeConnect(new ClusterEventArgs(node));
            }
            else
            {
                channel.Close();
            }
        }
コード例 #4
0
ファイル: GossipMember.cs プロジェクト: toomasz/emitter
 /// <summary>
 /// Serializes this packet to a binary stream.
 /// </summary>
 /// <param name="reader">PacketReader used to serialize the packet.</param>
 public override void Read(PacketReader reader)
 {
     MeshMember.TryParseEndpoint(reader.ReadString(), out this.EndPoint);
 }