netserver/newhwserv.hs
changeset 1350 99a921e292f4
parent 1341 86d7d5ab22a2
equal deleted inserted replaced
1349:49cf1e2edcd5 1350:99a921e292f4
    65 mainLoop :: Socket -> TChan ClientInfo -> [ClientInfo] -> [RoomInfo] -> IO ()
    65 mainLoop :: Socket -> TChan ClientInfo -> [ClientInfo] -> [RoomInfo] -> IO ()
    66 mainLoop servSock acceptChan clients rooms = do
    66 mainLoop servSock acceptChan clients rooms = do
    67 	r <- atomically $ (Left `fmap` readTChan acceptChan) `orElse` (Right `fmap` tselect clients)
    67 	r <- atomically $ (Left `fmap` readTChan acceptChan) `orElse` (Right `fmap` tselect clients)
    68 	case r of
    68 	case r of
    69 		Left ci -> do
    69 		Left ci -> do
    70 			mainLoop servSock acceptChan (ci:clients) rooms
    70 			mainLoop servSock acceptChan (clients ++ [ci]) rooms
    71 		Right (cmd, client) -> do
    71 		Right (cmd, client) -> do
    72 			putStrLn ("> " ++ show cmd)
    72 			putStrLn ("> " ++ show cmd)
    73 
    73 
    74 			let (clientsFunc, roomsFunc, answers) = handleCmd client clients rooms $ cmd
    74 			let (clientsFunc, roomsFunc, answers) = handleCmd client clients rooms $ cmd
    75 			let mrooms = roomsFunc rooms
    75 			let mrooms = roomsFunc rooms