gameServer/stresstest3.hs
branchexperimental3D
changeset 4004 b1c2c2f6fc5e
parent 3947 709fdb89f76c
equal deleted inserted replaced
3698:793386610068 4004:b1c2c2f6fc5e
    42         hPutStrLn h ""
    42         hPutStrLn h ""
    43         hFlush h
    43         hFlush h
    44 
    44 
    45 emulateSession :: StateT SState IO ()
    45 emulateSession :: StateT SState IO ()
    46 emulateSession = do
    46 emulateSession = do
    47     n <- io $ randomRIO (100000::Int, 100000)
    47     n <- io $ randomRIO (100000::Int, 100100)
    48     waitPacket "CONNECTED"
    48     waitPacket "CONNECTED"
    49     sendPacket ["NICK", "test" ++ (show n)]
    49     sendPacket ["NICK", "test" ++ (show n)]
    50     waitPacket "NICK"
    50     waitPacket "NICK"
    51     sendPacket ["PROTO", "31"]
    51     sendPacket ["PROTO", "31"]
    52     waitPacket "PROTO"
    52     waitPacket "PROTO"
    53     b <- waitPacket "LOBBY:JOINED"
    53     b <- waitPacket "LOBBY:JOINED"
    54     --io $ print b
    54     --io $ print b
       
    55     sendPacket ["QUIT", "BYE"]
    55     return ()
    56     return ()
    56 
    57 
    57 testing = Control.OldException.handle print $ do
    58 testing = Control.OldException.handle print $ do
    58     putStr "+"
    59     putStr "+"
    59     sock <- connectTo "127.0.0.1" (PortNumber 46631)
    60     sock <- connectTo "127.0.0.1" (PortNumber 46631)
    60     evalStateT emulateSession sock
    61     evalStateT emulateSession sock
    61     --hClose sock
    62     --hClose sock
    62     putStr "-"
    63     putStr "-"
    63     hFlush stdout
    64     hFlush stdout
    64 
    65 
    65 forks = forever $ do
    66 forks = forM_ [1..100] $ const $ do
    66     delay <- randomRIO (10000::Int, 30000)
    67     delay <- randomRIO (10000::Int, 30000)
    67     threadDelay delay
    68     threadDelay delay
    68     forkIO testing
    69     forkIO testing
    69 
    70 
    70 main = withSocketsDo $ do
    71 main = withSocketsDo $ do