Archived
1
0
Fork 0

Finished changing plugin data structure to Maps.

This commit is contained in:
Julien Dessaux 2010-02-04 20:38:06 +01:00
parent 884c6c9f2e
commit d2f40f6481
3 changed files with 24 additions and 9 deletions

View file

@ -7,6 +7,7 @@ import Control.Concurrent
import Control.Concurrent.Chan
import Control.Monad.State
import Data.List
import qualified Data.Map as M
import Network
import System.IO
import System.Time (getClockTime)
@ -28,13 +29,13 @@ connectServer server = do
chan <- newChan :: IO (Chan BotMsg)
threadId <- forkIO $ botReader handle chan
putStrLn "done."
return (Bot server starttime handle [] [] chan threadId)
return (Bot server starttime handle [] M.empty chan threadId M.empty)
-- | Disconnect from the server
disconnectServer :: Bot -> IO () -- IO Bot ?
disconnectServer bot = do
killThread $ readerThreadId bot
mapM_ (killThread . pluginThreadId) (botPlugins bot)
mapM_ (killThread . pluginThreadId . snd) (M.toList $ botPlugins bot)
hClose $ botHandle bot
return ()