add new game spam
This commit is contained in:
parent
3fc4237fcc
commit
43e312445b
3 changed files with 39 additions and 1 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -2468,6 +2468,9 @@ name = "socket_blaster"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
|
"lib",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"tungstenite",
|
"tungstenite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -6,3 +6,6 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4", features = ["cargo"] }
|
clap = { version = "4", features = ["cargo"] }
|
||||||
tungstenite = "0"
|
tungstenite = "0"
|
||||||
|
lib = { workspace = true }
|
||||||
|
serde_json = "1"
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|
|
@ -1,22 +1,54 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use clap::{command, Command};
|
use clap::{command, Command};
|
||||||
use tungstenite::connect;
|
use lib::*;
|
||||||
|
use serde_json::to_string;
|
||||||
|
use tungstenite::{connect, Message};
|
||||||
|
|
||||||
/// Infinite loop spawning new user connections and then leaving them open
|
/// Infinite loop spawning new user connections and then leaving them open
|
||||||
fn zombie_horde() {
|
fn zombie_horde() {
|
||||||
println!("Spamming new zombie user connections");
|
println!("Spamming new zombie user connections");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let (_, _) = connect("ws://127.0.0.1:3030/websocket").expect("Can't connect");
|
let (_, _) = connect("ws://127.0.0.1:3030/websocket").expect("Can't connect");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Infinite loop that creates games
|
||||||
|
fn spam_games() {
|
||||||
|
println!("Spamming game creation");
|
||||||
|
|
||||||
|
let mut packs = HashSet::new();
|
||||||
|
for pack in 0..205 {
|
||||||
|
packs.insert(pack.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
let (mut socket, _) = connect("ws://127.0.0.1:3030/websocket").expect("Can't connect");
|
||||||
|
loop {
|
||||||
|
socket
|
||||||
|
.send(Message::Text(
|
||||||
|
to_string(&NewGameRequest {
|
||||||
|
name: "ligma".to_string(),
|
||||||
|
packs: packs.clone(),
|
||||||
|
})
|
||||||
|
.unwrap(),
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let matches = command!()
|
let matches = command!()
|
||||||
.subcommand(
|
.subcommand(
|
||||||
Command::new("zombies")
|
Command::new("zombies")
|
||||||
.about("Infinite loop spawning new user connections and then leaving them open."),
|
.about("Infinite loop spawning new user connections and then leaving them open."),
|
||||||
)
|
)
|
||||||
|
.subcommand(Command::new("games").about("Infinite loop that creates games."))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
if matches.subcommand_matches("zombies").is_some() {
|
if matches.subcommand_matches("zombies").is_some() {
|
||||||
zombie_horde();
|
zombie_horde();
|
||||||
|
} else if matches.subcommand_matches("games").is_some() {
|
||||||
|
spam_games();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue