private void Server_AksUsersChatHistoryEvent(ChatUser askingUser, ChatUser targetUser) { verifyList(); /*if (IsChatClientsConnected(a,b) == false) * { * return; * }*/ //0. update that the asking user has read the chat, although he is going to read in a few seconds ChatDAL.UpdateUserChatDetailsToRead(askingUser, targetUser); //1. get history form db ChatDetails[] chatHistory = ChatDAL.GetChatDetailsForUsers(askingUser, targetUser); //2. send to clients if (myClients.ContainsKey(askingUser.UserAd) == false) { return;//should only happen with debug when acting as local user after opening another dev station //the new station is again local user and then connect as leaving only "as" user } myClients[askingUser.UserAd].client.RecieveUsersChatHistory(chatHistory, targetUser); if (IsChatClientsConnected(askingUser, targetUser) == true) { myClients[targetUser.UserAd].client.RecieveUsersChatHistory(chatHistory, askingUser); } }
private void Server_ClientSayEvent(string msg, ChatUser from, ChatUser to) { verifyList(); /*if (IsChatClientsConnected(from, to) == false) * { * return; * }*/ ChatDetails chatItem = new ChatDetails() { dateAdd = DateTime.Now, FromNumOved = from.NumOved, FromUserAd = from.UserAd, FromUserHeb = from.UserHeb, odaa = msg, ReadOdaa = false, ToNumOved = to.NumOved, ToUserAd = to.UserAd, ToUserHeb = to.UserHeb }; int id = DAL.insert <ChatDetails>("ChatDetail", chatItem); chatItem.id = id; if (IsChatClientsConnected(from, to) == true) { myClients[to.UserAd].client.RecieveFromClient(msg, from); } ChatDAL.UpdateUserChatDetailsToRead(from, to); }