Esempio n. 1
0
        public int execute(JoinCommand command)
        {
            // delay
            this.delay();

            if (this.isFrozen)
            {
                this.frozenCommands.Add(command);

                while (true)
                {
                    // freeze
                }

                return(0);
            }
            else
            {
                Console.WriteLine("Recieved " + command.getType() + "-" +
                                  command.getSequenceNumber() + " command from " + command.getIssuerId());

                MeetingProposal meeting = this.getMeetingByTopic(command.getTopic());

                if (meeting == null)
                {
                    Console.WriteLine("Meeting {0} not found, Contacting other servers ...", command.getTopic());
                    meeting = this.restoreLostMeeting(command.getTopic());

                    // Console.WriteLine("Meeting {0} not found, Waiting ...");
                    // Thread.Sleep(2000);

                    if (meeting == null)
                    {
                        Console.WriteLine("Meeting {0} not found", command.getTopic());
                        return(0);
                    }
                }

                if (meeting.isClosed() || meeting.isCancelled())
                {
                    // a client can join a closed meeting if it was joined before the closing momment
                    if (command.getTimestamp().CompareTo(meeting.getClosingTimestamp()) < 0)
                    {
                        meeting.open();
                        this.joinMeeting(command.getIssuerId(), meeting, command.getDesiredSlots());
                        meeting.close();
                    }
                }
                else
                {
                    this.joinMeeting(command.getIssuerId(), meeting, command.getDesiredSlots());
                }

                this.informOtherServers(command);

                return(1);
            }
        }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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;
 }