protected override void OnBindedToSession()
 {
     _clientSession = (SessionClientInterface)SessionInterface;
     _clientSession.RegisterNetMessageReceiver <NetMessagePlayerIdAssignment>(OnMsg_PlayerIdAssignement);
     _clientSession.RegisterNetMessageReceiver <NetMessagePlayerRepertoireSync>(OnMsg_NetMessagePlayerRepertoireSync);
     _clientSession.RegisterNetMessageReceiver <NetMessagePlayerJoined>(OnMsg_NetMessagePlayerJoined);
     _clientSession.RegisterNetMessageReceiver <NetMessagePlayerLeft>(OnMsg_NetMessagePlayerLeft);
     _clientSession.RegisterNetMessageReceiver <NetMessageSimPlayerIdAssignement>(OnMsg_NetMessageSimPlayerIdAssignement);
 }
Beispiel #2
0
    public override void OnGameAwake()
    {
        base.OnGameAwake();

        _session = OnlineService.ClientInterface?.SessionClientInterface;
        _session.RegisterNetMessageReceiver <NetMessagePlayerAssets>(OnAssetUpdatedByServer);
    }
Beispiel #3
0
    protected override IEnumerator ExecuteRoutine()
    {
        // request sync to server
        NetMessageRequestSimSync syncRequest = new NetMessageRequestSimSync();

        _sessionInterface.SendNetMessageToServer(syncRequest);

        // wait for server response
        _sessionInterface.RegisterNetMessageReceiver <NetMessageSerializedSimulation>(OnNetMessageSerializedSimulation);

        // wait for _loadPath to be assigned
        while (_receivedResponseFromServer == false)
        {
            yield return(null);
        }

        _sessionInterface.UnregisterNetMessageReceiver <NetMessageSerializedSimulation>(OnNetMessageSerializedSimulation);

        // terminate if load path is invalid
        if (_simData == null || _simData.Length == 0)
        {
            TerminateWithAbnormalFailure($"Invalid simulation data received from the server. Prehaps it failed to serialize it.");
            yield break;
        }

        yield return(ExecuteSubOperationAndWaitForSuccess(new Sim.Operations.SimDeserializationOperation(_simData, _simulationWorld)));

        TerminateWithSuccess();
    }
    public override void OnGameAwake()
    {
        base.OnGameAwake();

        _session = OnlineService.ClientInterface.SessionClientInterface;
        _session.RegisterNetMessageReceiver <NetMessageChatMessage>(OnNetMessageChatMessage);
    }
    protected override IEnumerator ExecuteRoutine()
    {
        // fbessette NB: As a first iteration, the server will save the simulation to a local text file.
        //               The client (on the same PC) will load the simulation from that text file.
        //               This will only work for "local" multiplayer (server and clients on the same PC).
        //
        //               In future iterations, the server should upload the simulation directly to the other player.

        // file name example: SerializedSim-515433


        // request sync to server
        NetMessageRequestSimSync syncRequest = new NetMessageRequestSimSync();

        _sessionInterface.SendNetMessageToServer(syncRequest);

        // wait for server response
        _sessionInterface.RegisterNetMessageReceiver <NetMessageSimSyncFromFile>(OnNetMessageSimSyncFromFile);

        // wait for _loadPath to be assigned
        while (_receivedResponseFromServer == false)
        {
            yield return(null);
        }
        _sessionInterface.UnregisterNetMessageReceiver <NetMessageSimSyncFromFile>(OnNetMessageSimSyncFromFile);

        // terminate if load path is invalid
        if (string.IsNullOrEmpty(_simLoadFile))
        {
            TerminateWithAbnormalFailure($"Invalid simulation load file path received from the server ({_simLoadFile}). Prehaps it failed to serialize it.");
            yield break;
        }

        yield return(ExecuteSubOperationAndWaitForSuccess(new LoadSimulationFromDiskOperation(_simLoadFile, _simulationWorld)));

        TerminateWithSuccess();
    }