// --- SERVER CALLBACKS --- void OnServerConnect(NetworkMessage msg) { // If we already have a fixed board size, send the newly-connected player the board size if (hasFixedBoardSize) { Debug.Log("[SERVER] ConnectFourBoardSetup : OnServerConnect - Sending connected client fixed board size of " + fixedBoardSize); var boardSizeMsg = new BoardSizeMessage() { playerId = fixedSizeSetByPlayerId, size = fixedBoardSize }; msg.conn.Send(ConnectFourMsgType.BoardSize, boardSizeMsg); } // If we have an offset set by either player, send it to the newly-connected player if (p1_offset != null) { Debug.Log("[SERVER] ConnectFourBoardSetup : OnServerConnect - Sending connected client player 1's board offset"); msg.conn.Send(ConnectFourMsgType.BoardOffset, p1_offset); } if (p2_offset != null) { Debug.Log("[SERVER] ConnectFourBoardSetup : OnServerConnect - Sending connected client player 2's board offset"); msg.conn.Send(ConnectFourMsgType.BoardOffset, p2_offset); } }
// Send BoardSizeMessage to server, only if the board size isn't fixed (i.e. the other player already set the board size) void SendBoardSizeMessage() { // Never send board size if we already have one, or if this is a headless instance if (hasFixedBoardSize || ConnectFourNPC.IsHeadlessMode()) { return; } var boardSizeMsg = new BoardSizeMessage() { playerId = NetworkManager.PlayerID, size = new Vector2(GetBoardWidth(), GetBoardHeight()), }; Debug.Log("[CLIENT] ConnectFourBoardSetup : SendBoardSizeMessage - Sending board size of " + boardSizeMsg.size); NetworkManager.Client.Send(ConnectFourMsgType.BoardSize, boardSizeMsg); }