TEST: change Datamodel from NSData to Data
This commit is contained in:
parent
106a0fe6de
commit
d99878eb47
@ -111,12 +111,13 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
|
|||||||
/*
|
/*
|
||||||
Vom match erhaltene Spielerdaten
|
Vom match erhaltene Spielerdaten
|
||||||
*/
|
*/
|
||||||
private func match(match: GKMatch!, didReceiveData data: NSData!,fromPlayer playerID: String!) {
|
private func match(match: GKMatch!, didReceiveData data: Data,fromPlayer playerID: String!) {
|
||||||
if mpMatch != match { return }
|
|
||||||
print("Daten empfangen!")
|
print("Daten empfangen!")
|
||||||
|
if mpMatch != match { return }
|
||||||
|
|
||||||
|
|
||||||
let pointer = UnsafeMutablePointer<Message>.allocate(capacity: MemoryLayout<Message>.size)
|
let pointer = UnsafeMutablePointer<Message>.allocate(capacity: MemoryLayout<Message>.size)
|
||||||
data.getBytes(pointer, length: MemoryLayout<Message>.size)
|
|
||||||
let message = pointer.move()
|
let message = pointer.move()
|
||||||
|
|
||||||
switch message.messageType{
|
switch message.messageType{
|
||||||
@ -128,7 +129,7 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate?.matchReceivedData(match: match, data: data, fromPlayer: playerID)
|
//delegate?.matchReceivedData(match: match, data: data, fromPlayer: playerID)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,11 +37,11 @@ class MultiplayerNetwork: NSObject{
|
|||||||
static let sharedInstance = MultiplayerNetwork()
|
static let sharedInstance = MultiplayerNetwork()
|
||||||
|
|
||||||
|
|
||||||
func sendData(data: NSData) {
|
func sendData(data: Data) {
|
||||||
let mmHelper = MatchmakingHelper.sharedInstance
|
let mmHelper = MatchmakingHelper.sharedInstance
|
||||||
if let multiplayerMatch = mmHelper.mpMatch {
|
if let multiplayerMatch = mmHelper.mpMatch {
|
||||||
do {
|
do {
|
||||||
try multiplayerMatch.sendData(toAllPlayers: data as Data, with: .reliable)
|
try multiplayerMatch.sendData(toAllPlayers: data, with: .reliable)
|
||||||
} catch {
|
} catch {
|
||||||
print("Tim war am Werk")
|
print("Tim war am Werk")
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ class MultiplayerNetwork: NSObject{
|
|||||||
var playerMoveMsg = PlayerMove(messageType: MessageType.PlayerMove, unitCount: unitcount)
|
var playerMoveMsg = PlayerMove(messageType: MessageType.PlayerMove, unitCount: unitcount)
|
||||||
|
|
||||||
|
|
||||||
let data = NSData(bytes: &playerMoveMsg, length: MemoryLayout<PlayerMove>.size)
|
let data = Data(bytes: &playerMoveMsg, count: MemoryLayout<PlayerMove>.size)
|
||||||
|
|
||||||
sendData(data: data)
|
sendData(data: data)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user