14
14
import System.Posix
17
session1 nick room = ["NICK", nick, "", "PROTO", "24", "", "CHAT", "lobby 1", "", "CREATE", room, "", "CHAT", "room 1", "", "QUIT", "bye-bye", ""]
18
session2 nick room = ["NICK", nick, "", "PROTO", "24", "", "LIST", "", "JOIN", room, "", "CHAT", "room 2", "", "PART", "", "CHAT", "lobby after part", "", "QUIT", "bye-bye", ""]
19
session3 nick room = ["NICK", nick, "", "PROTO", "24", "", "LIST", "", "JOIN", room, "", "CHAT", "room 2", "", "QUIT", "bye-bye", ""]
17
session 0 nick room = ["NICK", nick, "", "PROTO", "38", "", "PING", "", "CHAT", "lobby 1", "", "PONG", "", "CREATE_ROOM", room, "", "CHAT", "room 1", "", "QUIT", "creator", ""]
18
session 1 nick room = ["NICK", nick, "", "PROTO", "38", "", "LIST", "", "JOIN_ROOM", room, "", "PONG", "", "CHAT", "room 2", "", "PART", "", "CHAT", "lobby after part", "", "QUIT", "part-quit", ""]
19
session 2 nick room = ["NICK", nick, "", "PROTO", "38", "", "LIST", "", "JOIN_ROOM", room, "", "PONG", "", "CHAT", "room 2", "", "QUIT", "quit", ""]
20
session 3 nick room = ["NICK", nick, "", "PROTO", "38", "", "CHAT", "lobby 1", "", "CREATE_ROOM", room, "", "", "PONG", "CHAT", "room 1", "", "PART", "creator", "", "QUIT", "part-quit", ""]
21
22
emulateSession sock s = do
22
mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (50000::Int, 90000) >>= threadDelay) s
23
mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (100000::Int, 600000) >>= threadDelay) s
26
testing = Control.Exception.handle print $ do
27
testing = Control.OldException.handle print $ do
28
29
sock <- connectTo "127.0.0.1" (PortNumber 46631)
30
num1 <- randomRIO (70000::Int, 70100)
31
num2 <- randomRIO (0::Int, 2)
32
num3 <- randomRIO (0::Int, 5)
36
0 -> emulateSession sock $ session1 nick1 room1
37
1 -> emulateSession sock $ session2 nick1 room1
38
2 -> emulateSession sock $ session3 nick1 room1
31
num1 <- randomRIO (100000::Int, 101000)
32
num2 <- randomRIO (0::Int, 3)
33
num3 <- randomRIO (0::Int, 1000)
34
let nick1 = 'n' : show num1
35
let room1 = 'r' : show num3
36
emulateSession sock $ session num2 nick1 room1
42
40
forks = forever $ do
43
delay <- randomRIO (10000::Int, 19000)
41
delays <- randomRIO (0::Int, 2)
44
delay <- randomRIO (delays * 20000::Int, delays * 20000 + 50000)
47
48
main = withSocketsDo $ do
48
49
#if !defined(mingw32_HOST_OS)