234 (Just ci) <- gets clientIndex |
234 (Just ci) <- gets clientIndex |
235 ri <- clientRoomA |
235 ri <- clientRoomA |
236 rnc <- gets roomsClients |
236 rnc <- gets roomsClients |
237 newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri |
237 newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri |
238 newMaster <- io $ client'sM rnc id newMasterId |
238 newMaster <- io $ client'sM rnc id newMasterId |
|
239 oldRoomName <- io $ room'sM rnc name ri |
239 let newRoomName = nick newMaster |
240 let newRoomName = nick newMaster |
240 mapM_ processAction [ |
241 mapM_ processAction [ |
241 ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName}), |
242 ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName}), |
242 ModifyClient2 newMasterId (\c -> c{isMaster = True}), |
243 ModifyClient2 newMasterId (\c -> c{isMaster = True}), |
243 AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"] |
244 AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"] |
244 ] |
245 ] |
245 |
246 |
246 proto <- client's clientProto |
247 proto <- client's clientProto |
247 newRoom <- io $ room'sM rnc id ri |
248 newRoom <- io $ room'sM rnc id ri |
248 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
249 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
249 processAction $ AnswerClients chans ("ROOM" : "ADD" : roomInfo (nick newMaster) newRoom) |
250 processAction $ AnswerClients chans ("ROOM" : "UPD" : oldRoomName : roomInfo (nick newMaster) newRoom) |
250 |
251 |
251 processAction (AddRoom roomName roomPassword) = do |
252 processAction (AddRoom roomName roomPassword) = do |
252 Just clId <- gets clientIndex |
253 Just clId <- gets clientIndex |
253 rnc <- gets roomsClients |
254 rnc <- gets roomsClients |
254 proto <- client's clientProto |
255 proto <- client's clientProto |