예제 #1
0
        /// <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();
            }
        }
예제 #2
0
 /// <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);
 }