Finished changing plugin data structure to Maps.
This commit is contained in:
parent
884c6c9f2e
commit
d2f40f6481
3 changed files with 24 additions and 9 deletions
|
@ -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 ()
|
||||
|
||||
|
|
Reference in a new issue