From a8e0bac437f7b3090d35c2a7344c7433f7e5e81b Mon Sep 17 00:00:00 2001 From: Niko Jochim <82joni1bif@hft-stuttgart.de> Date: Wed, 13 May 2020 15:07:23 +0200 Subject: [PATCH] Change send modifications --- GoldWars/GoldWars/MessageProtocol.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/GoldWars/GoldWars/MessageProtocol.swift b/GoldWars/GoldWars/MessageProtocol.swift index 3d6d14f..21ed95c 100644 --- a/GoldWars/GoldWars/MessageProtocol.swift +++ b/GoldWars/GoldWars/MessageProtocol.swift @@ -46,12 +46,10 @@ class MultiplayerNetwork{ } func sendPlayerMove(unitcount:Int) { - var playerMoveMsg = PlayerMove(messageType: MessageType.PlayerMove, unitCount: unitcount) - - - let data = Data(bytes: &playerMoveMsg, count: MemoryLayout.size) - - sendData(data: data) + let playerMoveMsg = PlayerMove(messageType: MessageType.PlayerMove, unitCount: unitcount) + let encoder = JSONEncoder() + let encoded = (try? encoder.encode(playerMoveMsg))! + sendData(data: encoded) } }