private void DequeueMessages(MartinLayooIncChat.RoomType roomType) { Initialize(); if (roomType == MartinLayooIncChat.RoomType.PublicRoom) { lock (ChatResource.Rooms[ChatResource.PublicRoom]) { if (ChatResource.Rooms[ChatResource.PublicRoom].Count > 0) { currentClient = ChatResource.Rooms[ChatResource.PublicRoom].Dequeue(); currMesg = "<span id='clientMsg' style='color:Red;font-weight:bold;'><b>" + currentClient.Username + ": </b></span> " + currentClient.Message; } } } else//roomType == MartinLayooIncChat.RoomType.SecretRoom { lock (ChatResource.Rooms[ChatResource.SecretRoom]) { if (ChatResource.Rooms[ChatResource.SecretRoom].Count > 0) { currentClient = ChatResource.Rooms[ChatResource.SecretRoom].Dequeue(); if (ChatResource.userSecretList.Contains(currentClient)) { secCurrMesg = "<span id='clientMsg' style='color:Red;font-weight:bold;'><b>" + currentClient.Username + ": </b></span> " + currentClient.Message; } } } } }
public void InviteClient([FromBody] Client clt) { Initialize(); MartinLayooIncChat.RoomType roomType = (MartinLayooIncChat.RoomType)Enum.Parse(typeof(MartinLayooIncChat.RoomType), MartinLayooIncChat.RoomType.SecretRoom.ToString()); Client client = new Client(clt.Username, clt.Message); invitedClient = client.Username; AddMessagePublicRoom(clt); AddMessagePrivateRoom(clt); }
public string GetMessage(string room) { Initialize(); MartinLayooIncChat.RoomType roomType = (MartinLayooIncChat.RoomType)Enum.Parse(typeof(MartinLayooIncChat.RoomType), room); string mesg = null; if (roomType == MartinLayooIncChat.RoomType.PublicRoom) { if (HttpContext.Current.Session["PreviousMesg"] == null) { HttpContext.Current.Session["PreviousMesg"] = ""; } if ((currMesg != null && ((string)HttpContext.Current.Session["PreviousMesg"]) == currMesg) || currMesg == null) { DequeueMessages(roomType); } if ((string)HttpContext.Current.Session["PreviousMesg"] != currMesg) { mesg = currMesg; HttpContext.Current.Session["PreviousMesg"] = mesg; } return(mesg); } else { if (HttpContext.Current.Session["SecPreviousMesg"] == null) { HttpContext.Current.Session["SecPreviousMesg"] = ""; } if ((secCurrMesg != null && ((string)HttpContext.Current.Session["SecPreviousMesg"]) == secCurrMesg) || secCurrMesg == null) { DequeueMessages(roomType); } if ((string)HttpContext.Current.Session["SecPreviousMesg"] != secCurrMesg) { mesg = secCurrMesg; HttpContext.Current.Session["SecPreviousMesg"] = mesg; } return(mesg); } }