Merge branch 'master' of https://christophhagen.de/git/ch/SchafkopfServer
This commit is contained in:
commit
39835cdd2c
@ -174,4 +174,8 @@ final class SQLiteDatabase {
|
|||||||
}
|
}
|
||||||
return tables.play(card: card, player: player)
|
return tables.play(card: card, player: player)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func disconnectAllSockets() {
|
||||||
|
tables.disconnectAllSockets()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,4 +199,8 @@ final class TableManagement {
|
|||||||
// TODO: Save new table
|
// TODO: Save new table
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func disconnectAllSockets() {
|
||||||
|
tables.values.forEach { $0.disconnectAllPlayers() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,10 +84,4 @@ final class WeddingPlayer: CardHoldingPlayer {
|
|||||||
func replace(_ card: Card, with trumpCard: Card) {
|
func replace(_ card: Card, with trumpCard: Card) {
|
||||||
cards = (cards.filter { $0 != card } + [trumpCard]).sortedCards(forGame: .hochzeit)
|
cards = (cards.filter { $0 != card } + [trumpCard]).sortedCards(forGame: .hochzeit)
|
||||||
}
|
}
|
||||||
|
|
||||||
override var info: PlayerInfo {
|
|
||||||
var info = super.info
|
|
||||||
info.leadsGame = offersWedding || selectsGame
|
|
||||||
return info
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,10 @@ extension AbstractTable: ManageableTable {
|
|||||||
sendUpdateToAllPlayers()
|
sendUpdateToAllPlayers()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func disconnectAllPlayers() {
|
||||||
|
players.forEach { $0.disconnect() }
|
||||||
|
}
|
||||||
|
|
||||||
func sendUpdateToAllPlayers() {
|
func sendUpdateToAllPlayers() {
|
||||||
players.enumerated().forEach { playerIndex, player in
|
players.enumerated().forEach { playerIndex, player in
|
||||||
|
@ -31,4 +31,6 @@ protocol ManageableTable {
|
|||||||
func disconnect(player name: PlayerName)
|
func disconnect(player name: PlayerName)
|
||||||
|
|
||||||
func sendUpdateToAllPlayers()
|
func sendUpdateToAllPlayers()
|
||||||
|
|
||||||
|
func disconnectAllPlayers()
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,13 @@ public func configure(_ app: Application) throws {
|
|||||||
|
|
||||||
let db = app.databases.database(.sqlite, logger: .init(label: "Init"), on: app.databases.eventLoopGroup.next())!
|
let db = app.databases.database(.sqlite, logger: .init(label: "Init"), on: app.databases.eventLoopGroup.next())!
|
||||||
server = try SQLiteDatabase(db: db)
|
server = try SQLiteDatabase(db: db)
|
||||||
|
|
||||||
|
// Gracefully shut down by closing potentially open socket
|
||||||
|
DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + .seconds(5)) {
|
||||||
|
_ = app.server.onShutdown.always { _ in
|
||||||
|
server.disconnectAllSockets()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// register routes
|
// register routes
|
||||||
try routes(app)
|
try routes(app)
|
||||||
|
Loading…
Reference in New Issue
Block a user