private void on(OpponentConnectionStatus message) { Debug.Log("Opponent Disconnected, status: " + message.Status + " time remaining: " + message.TimeRemaining); matchInfoDisplay.GameState = "Paused by " + matchInfoDisplay.OpponentId + ", " + message.TimeRemaining + "s left..."; matchInfoDisplay.SetInputAllowed(false); }
public static Offset <OpponentConnectionStatus> CreateOpponentConnectionStatus(FlatBufferBuilder builder, short opcode = 9, short status = 0, short timeRemaining = 0) { builder.StartTable(3); OpponentConnectionStatus.AddTimeRemaining(builder, timeRemaining); OpponentConnectionStatus.AddStatus(builder, status); OpponentConnectionStatus.AddOpcode(builder, opcode); return(OpponentConnectionStatus.EndOpponentConnectionStatus(builder)); }
private void Update() { if (doAbort) { doAbort = false; AbortGame(); } if (didConnectSuccessfully) { didConnectSuccessfully = false; OnConnected(); } if (doAttemptConnect) { doAttemptConnect = false; OnAttemptingReconnect(); } if (!client.IsConnected && tickCount > 0 && !UserData.Instance.IsGameOver) { matchInfoDisplay.GameState = "Disconnected"; } // Process all packets that have been received by the server thus far byte[] data; while (client.GetNextPacket(out data)) { if (UserData.Instance.IsGameOver) { return; } var packet = PacketFactory.BytesToPacket(data); var byteBuffer = new ByteBuffer(data); // Uncomment for logs containing which packet type you receive // Debug.Log("SyncGameController: Received packet: " + (Opcode)packet.Opcode); switch ((Opcode)packet.Opcode) { case Opcode.MatchSuccess: client.ResetReadTimer(); on(MatchSuccess.GetRootAsMatchSuccess(byteBuffer)); client.SetReadTimeout(2000); break; case Opcode.GameState: on(GameState.GetRootAsGameState(byteBuffer)); break; case Opcode.MatchOver: on(MatchOver.GetRootAsMatchOver(byteBuffer)); break; case Opcode.OpponentConnectionStatus: on(OpponentConnectionStatus.GetRootAsOpponentConnectionStatus(byteBuffer)); break; case Opcode.PlayerReconnected: on(PlayerReconnected.GetRootAsPlayerReconnected(byteBuffer)); break; case Opcode.OpponentPaused: on(OpponentPaused.GetRootAsOpponentPaused(byteBuffer)); break; case Opcode.OpponentResumed: on(OpponentResumed.GetRootAsOpponentResumed(byteBuffer)); break; case Opcode.Chat: on(Chat.GetRootAsChat(byteBuffer)); break; case Opcode.KeepAlive: break; default: Debug.Log("SyncGameController: Received packet with unimplemented/unsupported authcode: " + packet.Opcode); break; } } }
public static OpponentConnectionStatus GetRootAsOpponentConnectionStatus(ByteBuffer _bb, OpponentConnectionStatus obj) { return(obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }