forked from foeLe/Software-Engineering-project-Spring-22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trafficGenerator.py
46 lines (36 loc) · 1.19 KB
/
trafficGenerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import asyncio
import websockets
import random
import time
def main():
print('this program will generate some test traffic for 2 players on the red ')
print('team as well as 2 players on the green team')
print('')
red1 = input('Enter id of red player 1 ==> ')
red2 = input('Enter id of red player 2 ==> ')
green1 = input('Enter id of green player 1 ==> ')
green2 = input('Enter id of green player 2 ==> ')
print('')
counter = input('How many events do you want ==> ')
i = 0
while i < int(counter):
if random.randint(1,2) == 1:
redplayer = red1
else:
redplayer = red2
if random.randint(1,2) == 1:
greenplayer = green1
else:
greenplayer = green2
if random.randint(1,2) == 1:
message = redplayer + ":" + greenplayer
else:
message = greenplayer + ":" + redplayer
print(message)
i+=1
asyncio.run(send(message))
time.sleep(random.randint(3,8))
async def send(data):
async with websockets.connect("wss://team-11-app.herokuapp.com") as websocket:
await websocket.send(data)
if(__name__=="__main__"):main()