public int pull(MeetingProposal meeting) { if (this.gossipedMeetings.Contains(meeting.getTopic())) { // Console.WriteLine(this.url + " stopped " + command.commandId()); return(0); } List <string> invitees = meeting.getInvitees(); if (invitees != null) { if (invitees.Contains(this.username)) { Console.WriteLine("You are invited to the meeting " + meeting.getTopic()); } } else { Console.WriteLine("A meeting " + meeting.getTopic() + " was created"); } this.gossipedMeetings.Add(meeting.getTopic()); List <string> clients = this.getClientsForGossip(); this.gossip(meeting, clients); return(1); }
private void createMeeting(string client_id, MeetingProposal proposal) { Monitor.Enter(this.meetings); proposal.setRoomsManager(this.roomsManager); if (!this.meetings.ContainsKey(client_id)) { this.meetings[client_id] = new HashSet <MeetingProposal>(); } bool already_exists = false; foreach (MeetingProposal meetingProposal in this.meetings[client_id]) { if (meetingProposal.getTopic() == proposal.getTopic()) { already_exists = true; break; } } if (!already_exists) { this.meetings[client_id].Add(proposal); } else { // merge two meetings MeetingProposal original = null; foreach (MeetingProposal meetingProposal in this.meetings[client_id]) { if (meetingProposal.getTopic() == proposal.getTopic()) { original = meetingProposal; this.meetings[client_id].Remove(meetingProposal); break; } } original = this.mergeTwoMeetings(original, proposal); this.meetings[client_id].Add(original); } Monitor.Exit(this.meetings); }
private void joinMeeting(string client_id, MeetingProposal proposal, List <Slot> desiredSlots) { Monitor.Enter(this.meetings); // client cannot join a meeting if it is closed or cancelled if (proposal.isClosed() || proposal.isCancelled()) { return; } proposal.addParticipant(client_id, desiredSlots); Console.WriteLine(client_id + " joined " + proposal.getTopic()); Monitor.Exit(this.meetings); }
public MeetingProposal(MeetingProposal proposal) { this.coordinator = proposal.getCoordinator(); this.topic = proposal.getTopic(); this.min_attendees = proposal.min_attendees; this.slots = proposal.getSlots(); this.invitees = proposal.invitees; this.closed = proposal.isClosed(); this.cancelled = proposal.isCancelled(); this.participants = proposal.getParticipants(); this.finalParticipants = proposal.getFinalParticipants(); this.closingTimestamp = proposal.getClosingTimestamp(); this.selectedRoom = proposal.selectedRoom; this.selectedSlot = proposal.selectedSlot; this.roomsManager = proposal.roomsManager; }
public override bool Equals(object obj) { MeetingProposal proposal = (MeetingProposal)obj; return(proposal.getTopic() == this.getTopic()); }