1

I'm trying to use the FMETP asset implementing the pun script following the information from the web page and the process that I'm doing in unity editor is object with FMETP Encoder assignig the FMStreamPun method to send the bit -> New Object with FMStreamPun script signing the FMETP Encoder.

Doing that the decoder doesn't receive the information from the encoder.

Do you know something about that topic?

This is the FMStreamPun Script

using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMETP;

public class FMStreamPun : Photon.Pun.MonoBehaviourPun, IPunObservable
{
    private Queue<byte[]> appendQueueSendData = new Queue<byte[]>();
    public int appendQueueSendDataCount { get { return appendQueueSendData.Count; } }

    public UnityEventByteArray OnDataByteReadyEvent = new UnityEventByteArray();

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        Debug.Log("entro al seriaize view");
        if (stream.IsWriting)
        {
            Debug.Log("is writting");
            //Send the meta data of the byte[] queue length
            stream.SendNext(appendQueueSendDataCount);
            //Sending the queued byte[]
            while (appendQueueSendDataCount > 0)
            {
                byte[] sentData = appendQueueSendData.Dequeue();
                stream.SendNext(sentData);
            }
        }

        if (stream.IsReading)
        {
            if (!photonView.IsMine)
            {
                //Get the queue length
                int streamCount = (int)stream.ReceiveNext();
                for (int i = 0; i < streamCount; i++)
                {
                    //reading stream one by one
                    byte[] receivedData = (byte[])stream.ReceiveNext();
                    OnDataByteReadyEvent.Invoke(receivedData);
                }
            }
        }
    }

    public void Action_SendData(byte[] inputData)
    {
        
        Debug.Log("entro al action send data");
        //inputData(byte[]) is the encoded byte[] from your encoder
        //doesn't require any stream, when there is only one player in the room
        //if (PhotonNetwork.CurrentRoom.PlayerCount > 1)
        //{
            appendQueueSendData.Enqueue(inputData);
        //}
    }
}

I'm using both assets but I can't find any way to receive the information ito de decoder

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Serchnm
  • 11
  • 1

1 Answers1

0

This is a general example of using PUN2 serial stream method, which requires at least 2 connected players. Otherwise, it won't stream. Meanwhile, make sure that you have photoview component included in your gameobject.

The whole setup is very straightforward: Encoder -> byte[] -> FMStreamPUN -> byte[] -> Decoder

You have to troubleshoot if the serial stream via PUN2 is working or not first.

imleoson
  • 142
  • 11