private void prvConvWindow_FormClosed(object sender, FormClosedEventArgs e) { //TODO : filter send to server by ifremoved from list<> privateConversation _temp = (privateConversation)sender; _temp.Dispose(); for (int index = 0; index < prvConversations.Count; index++) { if (prvConversations[index] == _temp) { prvConversations.Remove(_temp); closePrivate closePrv = new closePrivate(); closePrv.setWhoSent(username); closePrv.setToWho(_temp.withWho); dataTypes objectToSend = new dataTypes(); objectToSend.setType(typeof(closePrivate).ToString()); objectToSend.setObject(closePrv); netServ.sendObjectToServer(objectToSend); break; } } }
private void parseObject(dataTypes objReceived) { if (objReceived.objectType.Equals(typeof(messageToEveryone).ToString())) { messageToEveryone msg = (messageToEveryone)objReceived.myObject; clientMW.appendText("[" + msg.whoAmI + "] " + msg.message); } else if (objReceived.objectType.Equals(typeof(userList).ToString())) { userList onlineClients = (userList)objReceived.myObject; clientMW.appendUsers(onlineClients.users); } else if (objReceived.objectType.Equals(typeof(startPrivate).ToString())) { startPrivate startPRV = (startPrivate)objReceived.myObject; clientMW.startPrivateConversationByServer(startPRV.whoStarts); } else if (objReceived.objectType.Equals(typeof(privateMessage).ToString())) { privateMessage prvMsg = (privateMessage)objReceived.myObject; clientMW.pushPrivateToWindow(prvMsg); } else if (objReceived.objectType.Equals(typeof(closePrivate).ToString())) { closePrivate closePrv = (closePrivate)objReceived.myObject; clientMW.closePrivate(closePrv); } else { throw new Exception("Unsupported object type"); } }
internal void closePrivate(closePrivate closePrv) { privateConversation thisConversation = getWindowByUser(closePrv.whoSent); thisConversation.disableControls(); prvConversations.Remove(thisConversation); }
private void parseObject(dataTypes objReceived, Socket m_socWorker) { if (objReceived.objectType.Equals(typeof(loginInfo).ToString())) { loginInfo clientInfo = (loginInfo)objReceived.myObject; bool result = DS.isClientAuthorized((loginInfo)objReceived.myObject); if (result) { serverMW.appendDebugOutput("New client connecterd : " + clientInfo.username); } for (int i = 0; i < clients.Count; i++) { if (clients[i].getSocket() == m_socWorker) { clients[i].setName(clientInfo.username); } } userList connectedUsers = new userList(); for (int index = 0; index < clients.Count; index++) { connectedUsers.users.Add(clients[index].getUserName()); } STCB.sendUserlistToClients(connectedUsers); } else if (objReceived.objectType.Equals(typeof(messageToEveryone).ToString())) { messageToEveryone msg = (messageToEveryone)objReceived.myObject; STCB.sendMsgToAllClients(msg); } else if (objReceived.objectType.Equals(typeof(startPrivate).ToString())) { startPrivate startPRV = (startPrivate)objReceived.myObject; STCB.sendMsgToClient(startPRV.withWho, objReceived); } else if (objReceived.objectType.Equals(typeof(privateMessage).ToString())) { privateMessage prvMsg = (privateMessage)objReceived.myObject; STCB.sendMsgToClient(prvMsg.toWho, objReceived); } else if (objReceived.objectType.Equals(typeof(closePrivate).ToString())) { closePrivate closePrv = (closePrivate)objReceived.myObject; STCB.sendMsgToClient(closePrv.toWho, objReceived); } else { throw new Exception("Unsupported object type"); } }