This repository has been archived by the owner on Jul 21, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AutoMuteUs Support (with auethermuteproxy) (#1)
* Add Socket.IO Official Client (it might not work in Windows) * Use patched version of StarScream daltoniam/Starscream#844 * Use forked version of Starscream * update dependencies * update dependencies * remove socket.io client code * WIP: support lobby, state, player event * CI(Linux): Install libcurl-dev package * CI(Linux): Use libcurl4-openssl-dev insteadof libcurl-dev * Support gameend event & remove players after gameend/disconnect * README: ✅ Linked with AutoMuteUs * Add WindowsCompatibility.swift (sleep)
- Loading branch information
Showing
8 changed files
with
170 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by user on 2021/03/06. | ||
// | ||
|
||
import Foundation | ||
#if canImport(FoundationNetworking) | ||
import FoundationNetworking | ||
#endif | ||
|
||
extension CaptureState { | ||
enum GameScene: UInt8, Encodable { | ||
case lobby = 0 | ||
case tasks | ||
case discussion | ||
case menu | ||
case ended | ||
case unknown | ||
} | ||
|
||
func updateAutoMuteUsScene(scene: GameScene) { | ||
guard let url = muteProxyURL else { | ||
return | ||
} | ||
var req = URLRequest(url: url.appendingPathComponent("state/\(scene.rawValue)")) | ||
req.httpMethod = "POST" | ||
URLSession.shared.dataTask(with: req).resume() | ||
} | ||
|
||
func updateAutoMuteUsLobby(code: String, region: UInt8, map: UInt8) { | ||
guard let url = muteProxyURL else { | ||
return | ||
} | ||
var req = URLRequest(url: url.appendingPathComponent("lobby/\(code.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!)/\(region)/\(map)")) | ||
req.httpMethod = "POST" | ||
URLSession.shared.dataTask(with: req).resume() | ||
} | ||
|
||
enum PlayerUpdateAction: UInt8, Encodable { | ||
case joined = 0 | ||
case left | ||
case died | ||
case changedColor | ||
case forceUpdated | ||
case disconnected | ||
case exiled | ||
} | ||
func updateAutoMuteUsPlayer(player: Player, action: PlayerUpdateAction) { | ||
guard let url = muteProxyURL else { | ||
return | ||
} | ||
var req = URLRequest(url: url.appendingPathComponent([ | ||
"player", | ||
// we should add space for empty name (that is invalid, but we should handle invalid name) | ||
// last character is always trimmed by auethermuteproxy | ||
player.name.addingPercentEncoding(withAllowedCharacters: .alphanumerics)! + " ", | ||
action.rawValue.description, | ||
player.deadAt != nil ? "1" : "0", | ||
player.disconnectedAt != nil ? "1" : "0", | ||
player.color.rawValue.description, | ||
].joined(separator: "/"))) | ||
req.httpMethod = "POST" | ||
URLSession.shared.dataTask(with: req).resume() | ||
} | ||
|
||
func updateAutoMuteUsGameOver(reason: EndReason, players: [Player]) { | ||
guard let url = muteProxyURL else { | ||
return | ||
} | ||
var req = URLRequest(url: url.appendingPathComponent([ | ||
"gameover", | ||
reason.rawValue.description, | ||
players.map { [ | ||
$0.name.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!, | ||
gameState.impostors.contains($0.id) ? "1" : "0", | ||
].joined(separator: "_") }.joined(separator: ","), | ||
].joined(separator: "/"))) | ||
req.httpMethod = "POST" | ||
URLSession.shared.dataTask(with: req).resume() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by user on 2021/03/06. | ||
// | ||
|
||
#if os(Windows) | ||
import WinSDK | ||
func sleep(_ seconds: UInt32) { | ||
// Win32 Sleep is milliseconds, *NIX sleep is seconds | ||
Sleep(seconds * 1000) | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters