Photon Unity Networking: PhotonStream Class Reference

Photon Unity Networking

This container is used in OnPhotonSerializeView() to either provide incoming data of a PhotonView or for you to provide it. More...

Public Member Functions

 PhotonStream (bool write, object[] incomingData)
 Creates a stream and initializes it. Used by PUN internally. More...
 
void SetReadStream (object[] incomingData, byte pos=0)
 
object ReceiveNext ()
 Read next piece of data from the stream when isReading is true. More...
 
object PeekNext ()
 Read next piece of data from the stream without advancing the "current" item. More...
 
void SendNext (object obj)
 Add another piece of data to send it when isWriting is true. More...
 
object[] ToArray ()
 Turns the stream into a new object[]. More...
 
void Serialize (ref bool myBool)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref int myInt)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref string value)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref char value)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref short value)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref float obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref PhotonPlayer obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref Vector3 obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref Vector2 obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref Quaternion obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 

Properties

bool isWriting [get]
 If true, this client should add data to the stream to send it. More...
 
bool isReading [get]
 If true, this client should read data send by another client. More...
 
int Count [get]
 Count of items in the stream. More...
 

Detailed Description

This container is used in OnPhotonSerializeView() to either provide incoming data of a PhotonView or for you to provide it.

The isWriting property will be true if this client is the "owner" of the PhotonView (and thus the GameObject). Add data to the stream and it's sent via the server to the other players in a room. On the receiving side, isWriting is false and the data should be read.

Send as few data as possible to keep connection quality up. An empty PhotonStream will not be sent.

Use either Serialize() for reading and writing or SendNext() and ReceiveNext(). The latter two are just explicit read and write methods but do about the same work as Serialize(). It's a matter of preference which methods you use.

See also
PhotonNetworkingMessage

Constructor & Destructor Documentation

PhotonStream.PhotonStream ( bool  write,
object[]  incomingData 
)

Creates a stream and initializes it. Used by PUN internally.

Member Function Documentation

object PhotonStream.PeekNext ( )

Read next piece of data from the stream without advancing the "current" item.

object PhotonStream.ReceiveNext ( )

Read next piece of data from the stream when isReading is true.

void PhotonStream.SendNext ( object  obj)

Add another piece of data to send it when isWriting is true.

void PhotonStream.Serialize ( ref bool  myBool)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref int  myInt)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref string  value)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref char  value)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref short  value)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref float  obj)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref PhotonPlayer  obj)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref Vector3  obj)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref Vector2  obj)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.Serialize ( ref Quaternion  obj)

Will read or write the value, depending on the stream's isWriting value.

void PhotonStream.SetReadStream ( object[]  incomingData,
byte  pos = 0 
)
object [] PhotonStream.ToArray ( )

Turns the stream into a new object[].

Property Documentation

int PhotonStream.Count
get

Count of items in the stream.

bool PhotonStream.isReading
get

If true, this client should read data send by another client.

bool PhotonStream.isWriting
get

If true, this client should add data to the stream to send it.

Online Documentation  -  Dashboard  -  Support Forum Exit Games GmbH