internal static void Main() { var chatRoom = new ChatRoom(); Participant george = new Beetle("George"); Participant paul = new Beetle("Paul"); Participant ringo = new Beetle("Ringo"); Participant john = new Beetle("John"); Participant yoko = new NonBeetle("Yoko"); chatRoom.Register(george); chatRoom.Register(paul); chatRoom.Register(ringo); chatRoom.Register(john); chatRoom.Register(yoko); yoko.Send("John", "Hi John!"); paul.Send("Ringo", "All you need is love"); ringo.Send("George", "My sweet Lord"); paul.Send("John", "Can't buy me love"); john.Send("Yoko", "My sweet love"); // Wait for user Console.ReadKey(); }
static void Main(string[] args) { // Create chatroom ChatRoom chatroom = new ChatRoom(); Participant Eddie = new Actor("Eddie"); Participant Jennifer = new Actor("Jennifer"); Participant Bruce = new Actor("Bruce"); Participant Tom = new Actor("Tom"); Participant Tony = new NonActor("Tony"); // Create participants and register them chatroom.Register(Eddie); chatroom.Register(Jennifer); chatroom.Register(Bruce); chatroom.Register(Tom); chatroom.Register(Tony); // Chatting participants Tony.Send("Tom", "Hey Tom! I got a mission for you."); Jennifer.Send("Bruce", "Teach me to act and I'll" + " teach you to dance"); Bruce.Send("Eddie", "How come you don't do standup anymore?"); Jennifer.Send("Tom", "Do you like math?"); Tom.Send("Tony", "Teach me to sing."); // Wait for user Console.ReadKey(); }
static void Main(string[] args) { IChatRoom chatroom = new ChatRoom(); IChatClient alice = new ChatClient("Alice"); IChatClient bob = new ChatClient("Bob"); chatroom.Register(alice); chatroom.Register(bob); alice.Send("Bob", Message.Create("Hey Bob, how are you!")); bob.Send("Alice", Message.Create("Could be better.")); bob.Send("Alice", Message.Create("I'm a little under the weather.")); alice.Send("Bob", Message.Create("Get well soon! Much love, Alice x")); Console.WriteLine(); Console.WriteLine("Registered users:"); foreach (var user in chatroom.RegisteredUsers) { Console.WriteLine(user); } Console.ReadKey(); }
public static void Main(string[] args) { var chatroom = new ChatRoom(1, "Movies"); Participant george = new Actor(1, "George"); Participant paul = new Actor(2, "Paul"); Participant john = new Member(3, "John"); chatroom.Register(george); chatroom.Register(paul); chatroom.Register(john); paul.Send(george.Id, "All you need is love"); george.Send(john.Id, "Can't buy me love"); john.Send(paul.Id, "My sweet love"); paul.Send(1111, "unknown receiver"); Participant unregister = new Actor(101, "unregister participant"); unregister.Send(paul.Id, "Message from unregister participant"); Console.ReadKey(); }
public void Main() { var chatRoom = new ChatRoom(); Participant george = new Beatle("George"); Participant paul = new Beatle("Paul"); Participant ringo = new Beatle("Ringo"); Participant john = new Beatle("John"); Participant yoko = new NonBeatle("Yoko"); chatRoom.Register(george); chatRoom.Register(paul); chatRoom.Register(ringo); chatRoom.Register(john); chatRoom.Register(yoko); yoko.Send("John", "Hi John!"); paul.Send("Ringo", "All you need is love"); ringo.Send("George", "My sweet Lord"); paul.Send("John", "Can't buy me love"); john.Send("Yoko", "My sweet love"); Console.ReadKey(); }
static void Main(string[] args) { ChatRoom room = new ChatRoom(); User user1 = new ChatUser("Antonio"); User user2 = new ChatUser("Matilda"); User user3 = new ChatUser("Caterina"); room.Register(user1); room.Register(user2); room.Register(user3); user1.Send("Prova 1", null); //invia a tutti user2.Send("Ciao", "Antonio"); //invia solo ad Antonio Console.ReadLine(); }
static void Main(string[] args) { ChatRoom chatRoom = new ChatRoom(); User user1 = new User("user1"); User user2 = new User("user2"); User user3 = new User("user3"); chatRoom.Register(user1); chatRoom.Register(user2); chatRoom.Register(user3); chatRoom.Send("hello", user1, user2); user1.Send(user2, "hello 2"); Console.WriteLine(" "); chatRoom.SendAll("hello all"); }
static void Main(string[] args) { //Initialize the Mediator and colleagues AbstractChatRoom chatRoom = new ChatRoom(); Participant ross = new Actor("Ross"); ross.ChatRoom = chatRoom; Participant rachel = new Actor("Rachel"); rachel.ChatRoom = chatRoom; Participant monica = new NonActor("Monica"); monica.ChatRoom = chatRoom; Participant phoebe = new NonActor("Phoebe"); phoebe.ChatRoom = chatRoom; Participant joey = new Actor("Joey"); joey.ChatRoom = chatRoom; Participant chandler = new Actor("Chandler"); chandler.ChatRoom = chatRoom; //Register the colleagues to the mediator chatRoom.Register(ross); chatRoom.Register(rachel); chatRoom.Register(monica); chatRoom.Register(phoebe); chatRoom.Register(joey); chatRoom.Register(chandler); //Send messages between the participants. joey.Send("Chandler", "How you doing"); chandler.Send("Monica", "How are you dear"); monica.Send("Ross", "How are you brother"); ross.Send("Rachel", "How are you rachel"); rachel.Send("Phoebe", "You are a good human"); phoebe.Send("Joey", "Let's party"); }
public void EnterChatRoom(ChatRoom chatRoom) { _chatRoom = chatRoom; Id = chatRoom.Register(this); }