// Constructor. internal MembershipInfo(SpreadConnection connection, SpreadMessage message, bool daemonEndianMismatch) { // Set local variables. this.serviceType = message.ServiceType; this.group = message.Sender; this.members = message.Groups; // Is this a regular membership message. if (IsRegularMembership) { // Extract the groupID. int dataIndex = 0; int[] id = new int[3]; id[0] = SpreadConnection.toInt(message.Data, dataIndex); dataIndex += 4; id[1] = SpreadConnection.toInt(message.Data, dataIndex); dataIndex += 4; id[2] = SpreadConnection.toInt(message.Data, dataIndex); dataIndex += 4; // Endian-flip? if (daemonEndianMismatch) { id[0] = SpreadConnection.flip(id[0]); id[1] = SpreadConnection.flip(id[1]); id[2] = SpreadConnection.flip(id[2]); } // Create the group ID. this.groupID = new GroupID(id[0], id[1], id[2]); // Get the number of groups. int numGroups = SpreadConnection.toInt(message.Data, dataIndex); if (daemonEndianMismatch) { numGroups = SpreadConnection.flip(numGroups); } dataIndex += 4; // Get the groups. this.groups = new SpreadGroup[numGroups]; for (int i = 0; i < numGroups; i++) { this.groups[i] = connection.toGroup(message.Data, dataIndex); dataIndex += SpreadConnection.MAX_GROUP_NAME; } } }
// Returns true if the object represents the same group ID. /** * Returns true if the two GroupID's represent the same group membership view at the same point in time * in the history of the group. * * @param object a GroupID to compare against * @return true if object is a GroupID object and the two GroupID's are the same */ public override bool Equals(Object o) { // Check if it's the correct class. if (o == null || GetType() != o.GetType()) { return(false); } // Check if the ID's are the same. GroupID other = (GroupID)o; int[] otherID = other.ID; for (int i = 0; i < 3; i++) { if (id[i] != otherID[i]) { // The ID's are different. return(false); } } // No differences, the ID's are the same. return(true); }