public ActionResult Details(Guid?roomId) { if (roomId.HasValue) { IChatroom room = manager.Get(roomId.Value); ChatroomViewModel model = new ChatroomViewModel(); if (room != null) { model.Chatroom = room; model.roomId = roomId.Value; string PIN = TempData["PIN"] as string; TempData.Remove("PIN"); if (!string.IsNullOrWhiteSpace(PIN)) { model.PIN = PIN; model.Users = room.GetUsers(PIN); model.IsOwner = room.IsOwner(PIN); } if (room != null) { return(View(model)); } } } Error("Chat o podanym adresie nie istnieje!"); return(RedirectToAction("Index", "Home")); }
private void buttonAccéderSalons_Click(object sender, EventArgs e) // A MODIFIER { if (comboBox1.Text == "" || comboBox1.Text == "Selectionner") { labelErrorCreaSal.Text = "Merci de choisir un salon parmi la liste !"; labelErrorCreaSal.Show(); } else { if (labelStartServeur.Text == "Etat du Server : ON") { IChatroom iChatRoom = clientGT.joinTopic(comboBox1.Text); iChatRoom.join(chatter); RoomTab room = new RoomTab(this, iChatRoom); rooms.Add(room); ((ClientChatRoom)iChatRoom).room = room; iChatRoom.post(" s'est connecté", chatter); } else { tabControl1.SelectedTab = tabControl1.TabPages["tabPage1"]; MessageBox.Show("Merci de lancer le serveur !", "Aucun server lancé"); labelStartServeur.Text = "Merci de lancer le serveur !"; } } }
public ActionResult Details(Guid?roomId, string PIN) { ChatroomViewModel model = new ChatroomViewModel(); room = null; if (roomId.HasValue) { room = manager.Get(roomId.Value) as ChatroomLite; if (room != null) { model.Chatroom = room; model.PIN = PIN; model.roomId = roomId.Value; model.IsOwner = room.IsOwner(PIN); } model.Users = room.GetUsers(model.PIN); Save(); return(View(model)); } Error("Chat o podanym adresie nie istnieje!"); return(RedirectToAction("Index", "Home")); }
public JsonResult Push(Guid roomId, string PIN, string Message) { Message = Regex.Replace(Message, "<", "<"); Message = Regex.Replace(Message, ">", ">"); Message = Regex.Replace(Message, "\"", """); Message = Regex.Replace(Message, "'", "'"); string accessMessage = string.Empty; ChatResult result = null; IChatroom room = manager.Get(roomId); if (room != null) { result = room.Push(PIN, Message); Save(); } if (result == null && !string.IsNullOrEmpty(PIN)) { accessMessage = "Twój slot został zamknięty!"; } if (room == null) { accessMessage = "Chat został zamknięty!"; } return(generateJsonChat(result, accessMessage, PIN)); }
private void RetrieveChatRoom(string nameServiceHost, int nameServicePort) { CorbaInit init = CorbaInit.GetInit(); NamingContext nameService = (NamingContext)init.GetNameService(nameServiceHost, nameServicePort); NameComponent[] name = new NameComponent[] { new NameComponent("chatroom", "") }; // get the chatroom m_chatroom = (IChatroom)nameService.resolve(name); }
public ChatResult(IChatroom room, List <Message> messages, string pin) { Messages = messages; Pin = pin; if (room != null) { Users = room.Users(pin); Incidents = room.Incidents(pin); Expiration = calculateExpiration(room); } }
public ChatResult(IChatroom room, string author, string message, string pin, Message.Status status = Message.Status.Info) { Messages = new List <Message>(); Messages.Add(new Message(1, author, message, status)); Pin = pin; if (room != null) { Users = room.Users(pin); Incidents = room.Incidents(pin); Expiration = calculateExpiration(room); } }
public JsonResult ExtendTime(Guid roomId, string PIN) { IChatroom room = manager.Get(roomId); if (room != null) { ChatResult result = room.ExtendTime(PIN); return(Json(null, JsonRequestBehavior.DenyGet)); } else { return(Json("Chat o podanym adresie nie istnieje!", JsonRequestBehavior.DenyGet)); } }
public RoomTab(InfoUser infoUser,IChatroom iChatRoom) { this.infoUser = infoUser; this.iChatRoom = iChatRoom; initTab(); initButtonQuitter(); initTextBox(); initButtonEnvoyer(); initRichTextBox(); Controls.Add(buttonQuitter); Controls.Add(textBoxConv); Controls.Add(buttonEnvoyer); Controls.Add(richTextBoxMsg); }
public ActionResult ResetIncidents(Guid roomId, string PIN) { IChatroom room = manager.Get(roomId); if (room != null) { room.ClearIncidents(PIN); return(Json(null, JsonRequestBehavior.DenyGet)); } else { return(Json("Chat o podanym adresie nie istnieje!", JsonRequestBehavior.DenyGet)); } }
public RoomTab(InfoUser infoUser, IChatroom iChatRoom) { this.infoUser = infoUser; this.iChatRoom = iChatRoom; initTab(); initButtonQuitter(); initTextBox(); initButtonEnvoyer(); initRichTextBox(); Controls.Add(buttonQuitter); Controls.Add(textBoxConv); Controls.Add(buttonEnvoyer); Controls.Add(richTextBoxMsg); }
public JsonResult Kick(Guid roomId, string PIN, Guid UserId) { IChatroom room = manager.Get(roomId); if (room != null) { room.Kick(PIN, UserId); Save(); return(Json(null, JsonRequestBehavior.DenyGet)); } else { return(Json("Chat o podanym adresie nie istnieje!", JsonRequestBehavior.DenyGet)); } }
public ActionResult Create(string Name, string Nick) { if (string.IsNullOrWhiteSpace(Name)) { Name = "Anonymous"; } if (string.IsNullOrWhiteSpace(Nick)) { Nick = "Anonymous"; } ChatResult result = null; room = manager.Add(Name, Nick, out result); TempData["PIN"] = result.Pin; Save(); return(RedirectToAction("Details", new { roomId = room.ChatroomID })); }
public JsonResult Pull(Guid roomId, string PIN) { string accessMessage = string.Empty; ChatResult result = null; IChatroom room = manager.Get(roomId); if (room != null) { result = room.Pull(PIN); } if (result == null && !string.IsNullOrEmpty(PIN)) { accessMessage = "Twój slot został zamknięty!"; } if (room == null) { accessMessage = "Chat został zamknięty!"; } return(generateJsonChat(result, accessMessage, PIN)); }
private int calculateExpiration(IChatroom room) { return(100 * (int)((DateTime.Now - room.ExpirationStartsAt).Duration().TotalSeconds) / (room.TTLInMinutes * 60)); }
public static void test() { IPAddress Ip = IPAddress.Parse("127.0.0.1"); int port = 55555; ServerGestTopics server = new ServerGestTopics(Ip); ParameterizedThreadStart ts = new ParameterizedThreadStart(server.startServer); Thread t = new Thread(ts); t.Start(port); ClientGestTopics client1 = new ClientGestTopics(Ip, port); Thread test1 = new Thread(new ThreadStart(client1.connect)); test1.Start(); ClientGestTopics client2 = new ClientGestTopics(Ip, port); Thread test2 = new Thread(new ThreadStart(client2.connect)); test2.Start(); try { client1.addUser("bob", "123"); Console.WriteLine("Bob has been added !"); client1.removeUser("bob"); Console.WriteLine("Bob has been removed !"); client1.removeUser("bob"); Console.WriteLine("Bob has been removes twice !"); } catch (UserUnknownException e) { Console.WriteLine(e.login + " : user unknown (enable to remove)!"); } catch (UserExistsException e) { Console.WriteLine(e.login + " has already been added !"); } // authentification try { client1.addUser("bob", "123"); Console.WriteLine("Bob has been added !"); client2.authentify("bob", "123"); Console.WriteLine("Authentification OK !"); client2.authentify("bob", "456"); Console.WriteLine("Invalid password !"); } catch (WrongPasswordException e) { Console.WriteLine(e.login + " has provided an invalid password !"); } catch (UserExistsException e) { Console.WriteLine(e.login + " has already been added !"); } catch (UserUnknownException e) { Console.WriteLine(e.login + " : user unknown (enable to remove)!"); } // persistance try { server.save("users.txt"); AuthentificationManager am1 = new Authentification(); am1.load("users.txt"); am1.authentify("bob", "123"); Console.WriteLine("Loading complete !"); } catch (UserUnknownException e) { Console.WriteLine(e.login + " is unknown ! error during the saving/loading."); } catch (WrongPasswordException e) { Console.WriteLine(e.login + " has provided an invalid password !error during the saving/loading."); } catch (UserExistsException e) { Console.WriteLine(e.login + " has already been added !error during the saving/loading."); } catch (Exception e) { Console.WriteLine(e); } client1.createTopic("Ruby"); client1.createTopic("Java"); client2.createTopic("PHP"); Console.WriteLine("Topics list : " + client1.listTopics()); IChatroom cr2 = client2.joinTopic("PHP"); IChatroom cr1 = client1.joinTopic("PHP"); IChatter bob = new TextChatter("Bob"); IChatter joe = new TextChatter("Joe"); cr1.join(bob); cr1.post("Je suis seul ou quoi ?", bob); cr2.join(joe); cr1.post("Tiens, salut Bob !", bob); cr2.post("Yop", joe); cr1.quit(bob); cr2.post("Toi aussi tu chat sur les forums de jeux pendant les TP,Bob ?", joe); }
public Person(string name, IChatroom chatroom) { this.name = name; this.freshentry = true; chatroom.addPerson(this); }
private void RetrieveChatRoom(string nameServiceHost, int nameServicePort) { CorbaInit init = CorbaInit.GetInit(); NamingContext nameService = (NamingContext)init.GetNameService(nameServiceHost, nameServicePort); NameComponent[] name = new NameComponent[] { new NameComponent("chatroom", "") }; // get the chatroom m_chatroom = (IChatroom) nameService.resolve(name); }
public override void gereClient(TcpClient comm) { ns = comm.GetStream(); while (comm.Connected) { Message message = getMessage(); Message reply; try { switch (message.head.type) { case MessageType.LISTE_TOPICS: reply = new Message(new Header("Server", MessageType.LISTE_TOPICS_REPLY), listTopics()); sendMessage(reply); break; case MessageType.CREATE_TOPIC: createTopic(message.data); confirm(); break; case MessageType.JOIN_TOPIC: IChatroom scr = joinTopic(message.data); int port = ((ServerChatRoom)scr).port; reply = new Message(new Header("Server", MessageType.JOIN_REPLY), port.ToString()); sendMessage(reply); break; case MessageType.ADD_USER: String[] userInfo = message.data.Split(';'); addUser(userInfo[0], userInfo[1]); confirm(); break; case MessageType.RM_USER: removeUser(message.data); confirm(); break; case MessageType.AUTH_USER: userInfo = message.data.Split(';'); authentify(userInfo[0], userInfo[1]); confirm(); break; default: break; } } catch (UserUnknownException e) { sendAuthError(ErrorType.USER_UNKNOWN, e); } catch (UserExistsException e) { sendAuthError(ErrorType.USER_EXISTING, e); } catch (WrongPasswordException e) { sendAuthError(ErrorType.WRONG_PWD, e); } catch (TopicExistsException e) { reply = new Message(new Header("Server", MessageType.ERROR), ErrorType.TOPIC_EXISTING + ";" + e.Message); sendMessage(reply); } catch (Exception e) { reply = new Message(new Header("Server", MessageType.ERROR), ErrorType.UNKNOWN_EX + ";" + e.Message); sendMessage(reply); } } }
public ChatroomController(IChatroom chatroomService, IMapper mapper) { _chatroomService = chatroomService; _mapper = mapper; }
public ChatResult(IChatroom room, string author, string message, string pin, bool shouldTerminate, Message.Status status) : this(room, author, message, pin, status) { Terminate = shouldTerminate; }
public ChatResult(IChatroom room, List <Message> messages, string pin, bool shouldTerminate) : this(room, messages, pin) { Terminate = shouldTerminate; }