PSHomeCacheDepot / DEV /1.86 Docs /Libraries /ReceivedMessage+OutboundMessage.txt
pebxcvi's picture
big update
d7bb13e
1.68 ReceivedMessage .583
1.68.1 ReceivedMessage.GetEventMessage .583
1.68.2 ReceivedMessage.GetRemainingSize .584
1.68.3 ReceivedMessage.GetSenderPersonld .584
1.68.4 ReceivedMessage.GetTotalSize .585
1.68.5 ReceivedMessage.GetType .585
1.68.6 ReceivedMessage.ReadBiglnt .586
1.68.7 ReceivedMessage.ReadFloat .587
1.68.8 ReceivedMessage.Readlnt8 .587
1.68.9 ReceivedMessage.Readlntl 6 .588
1.68.10 ReceivedMessage.Readlnt32 . 589
1.68.11 ReceivedMessage.ReadString .589
1.62 OutboundMessage .505
1.62.1 OutboundMessage.Create .505
1.62.2 OutboundMessage.GetRemainingBufferSize .505
1.62.3 OutboundMessage.Reset .506
1.62.4 OutboundMessage.Send .506
1.62.5 OutboundMessage.SendUnguaranteed .507
1.62.6 OutboundMessage.WriteBiglnt .508
1.62.7 OutboundMessage.WriteFloat .508
1.62.8 OutboundMessage.Writelnt8 .509
1.62.9 OutboundMessage.Writelntl 6 .510
1.62.10 OutboundMessage.Writelnt32 .510
1.62.11 OutboundMessage.WriteString .511
ReceivedMessage
ReceivedMessage.GetEventMessage
Brief
Returns an instance of the message that is the focus of the current event.
Definition
ReceivedMessage ReceivedMessage.GetEventMessage()
Arguments
None
Return Values
The last message received as a ReceivedMessage.
Description
Returns an instance of the message that is the focus of the current event. Only valid during a message received event, as named by the
'on_received_message' property of the 'network' object component in the HDK's Object Editor application.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
data = ReceivedMessage.Readlnt32( message )
end
See Also
ReceivedMessage. Readlnt32
ReceivedMessage.GetRemainingSize
Brief
Returns the size of the unread data in the message.
Definition
number ReceivedMessage.GetRemainingSize( ReceivedMessage msg )
Arguments
msg - The instance of the received message to query.
Return Values
The number of bytes remaining in the message.
Description
Returns the size of the unread data in the message in bytes.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
bytesToRead = ReceivedMessage.GetRemainingSize( message )
print( bytesToRead ) � Prints total size
data = ReceivedMessage.Readlnt32( message )
bytesToRead = ReceivedMessage.GetRemainingSize( message )
print( bytesToRead ) � Prints total size - 4
end
See Also
� ReceivedMessage.GetEventMessage
ReceivedMessage.GetSenderPersonld
Brief
Returns the person id of the sender of the message.
Definition
! string ReceivedMessage.GetSenderPersonld( ReceivedMessage msg )
Arguments
msg - The instance of the received message to query.
Return Values
The sender's person id as a string.
Description
Returns the person id of the sender of the message.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
personid = ReceivedMessage.GetSenderPersonld( message )
print( personid )
end
See Also
� Person.Findlnlnstance
� Person.GetPosition
� ReceivedMessage.GetEventMessage
ReceivedMessage.GetTotalSize
Brief
Returns the total size of a received message.
Definition
! number ReceivedMessage.GetTotalSize( ReceivedMessage msg )
Arguments
msg - The instance of the received message to query.
Return Values
The size in bytes of the message.
Description
Returns the total size of a received message in bytes.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
messagesize = ReceivedMessage.GetTotalSize( message )
print( messagesize )
end
See Also
� ReceivedMessage.GetEventMessage
ReceivedMessage.GetType
Brief
Returns the type of a ReceivedMessage.
Definition
number ReceivedMessage.GetType( ReceivedMessage msg )
Arguments
msg - The instance of the received message to query.
Return Values
The message type as a number.
Description
Returns the user-defined type of a ReceivedMessage. The type is a value that is set by the script when the message is created by the sender.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
messagetype = ReceivedMessage.GetType( message )
print( "Message type is " .. messagetype )
end
See Also
� ReceivedMessage.GetEventMessage
ReceivedMessage.ReadBiglnt
Brief
Read a Biglnt value from a received message.
Definition
ReceivedMessage.ReadBiglnt( OutboundMessage msg, Biglnt biglnt )
Arguments
msg - The message.biglnt - The Biglnt to receive the value.
Return Values
None.
Description
Reads a Biglnt value from a received message. Any size of Biglnt is permissible.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
local biglnt = Biglnt.Create(64)
ReceivedMessage.ReadBiglnt( message, biglnt )
print( "Received big int:", biglnt )
end
See Also
� OutboundMessage.WriteBiglnt
� Biglnt.Create
Received Message. Read Float
Brief
Reads a 32-bit floating point value from the message.
Definition
number ReceivedMessage.ReadFloat( ReceivedMessage msg )
Arguments
msg - The instance of the received message to read from.
Return Values
32-bit floating point value read from the message packet.
Description
Reads a 32-bit floating point value from the message. When reading past the end of the message buffer, the function will silently fail and return 0.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
data = ReceivedMessage.ReadFloat( message )
print( "Received floating point value is " .. data )
end
See Also
� ReceivedMessage.Readlnt8
� ReceivedMessage.Readlntl 6
� ReceivedMessage.Readlnt32
� ReceivedMessage. ReadString
ReceivedMessage.Readlnt8
Brief
Reads an 8-bit integer from the message.
Definition
number ReceivedMessage.Readlnt8( ReceivedMessage msg )
Arguments
msg - The instance of the received message to read from.
Return Values
8-bit integer read from the message packet.
Description
Reads an 8-bit integer (or byte) from the message. When reading past the end of the message buffer, the function will silently fail and return 0.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
data = ReceivedMessage.Readlnt8( message )
print( "Received byte value is " .. data )
end
See Also
� ReceivedMessage.Readlntl 6
� ReceivedMessage.Readlnt32
� ReceivedMessage.ReadFloat
� ReceivedMessage.ReadString
ReceivedMessage.Readlntl 6
Brief
Reads a 16-bit integer from the message.
Definition
! number ReceivedMessage.Readlntl6( ReceivedMessage msg )
Arguments
msg - The instance of the received message to read from.
Return Values
16-bit integer read from the message packet.
Description
Reads a 16-bit integer (or short) from the message. When reading past the end of the message buffer, the function will silently fail and return 0.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
data = ReceivedMessage.Readlntl6( message )
print( "Received short value is " .. data )
end
See Also
ReceivedMessage. Readlnt8
� ReceivedMessage.Readlnt32
� ReceivedMessage.ReadFloat
� ReceivedMessage.ReadString
ReceivedMessage.Readlnt32
Brief
Reads a 32-bit integer from the message.
Definition
! number ReceivedMessage.Readlnt32( ReceivedMessage msg )
Arguments
msg - The instance of the received message to read from.
Return Values
32-bit integer read from the message packet.
Description
Reads a 32-bit integer from the message. When reading past the end of the message buffer, the function will silently fail and return 0.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
data = ReceivedMessage.Readlnt32( message )
print( "Received integer value is " .. data )
end
See Also
� ReceivedMessage.Readlnt8
� ReceivedMessage.Readlntl 6
� ReceivedMessage.ReadFloat
� ReceivedMessage.ReadString
ReceivedMessage.ReadString
Brief
Reads a string value from the message.
Definition
! number ReceivedMessage.ReadString( ReceivedMessage msg )
Arguments
msg - The instance of the received message to read from.
Return Values
String value read from the message packet.
Description
Reads a string value from the message. When reading past the end of the message buffer, the function will silently fail and return the empty
string.
Examples
function OnReceivedMessage()
local message = ReceivedMessage.GetEventMessage()
data = ReceivedMessage.Readstring( message )
print( "Received string value is " .. data )
end
See Also
� ReceivedMessage.Readlnt8
� ReceivedMessage.Readlntl 6
� ReceivedMessage.Readlnt32
� ReceivedMessage.ReadFloat
OutboundMessage
OutboundMessage.Create
Brief
Creates a new OutboundMessage for sending.
Definition
! OutboundMessage OutboundMessage.Create( number messageType, number bufferSize )
Arguments
messageType - Message type as a number. This is free for the script to set and is sent as an int32.bufferSize - Size of the buffer to write the
message to. This should be equal to the size of the data you want to include in the message.
Return Values
A new instance of an OutboundMessage.
Description
Creates a new OutboundMessage for sending. The size for the buffer will be allocated out of the script's network environment (currently the global
network pool).
Examples
! local message = OutboundMessage.Create( 12345, 16 )
See Also
None
OutboundMessage.GetRemainingBufferSize
Brief
Returns the space remaining in the message's buffer.
Definition
! number OutboundMessage.GetRemainingBufferSize( OutboundMessage msg )
Arguments
msg - The instance of the message to query.
Return Values
The remaining buffer space in bytes.
Description
Returns the space remaining in the message's buffer.
Examples
local size = OutboundMessage.GetRemainingBufferSize( message )
See Also
None
OutboundMessage.Reset
Brief
Resets the buffer for the OutboundMessage.
Definition
! OutboundMessage.Reset( OutboundMessage msg )
Arguments
msg - The instance of the message to reset.
Return Values
None.
Description
Resets the message buffer for the OutboundMessage so that it can be used again with new contents.
Examples
local message = OutboundMessage.Create( 0, 4 )
OutboundMessage.Writelntl6( message, valuel )
OutboundMessage.Writelntl6( message, value2 )
OutboundMessage.Send( message, personld )
� Reuse message
OutboundMessage.Reset( message )
OutboundMessage.Writelnt32( message, value3 )
OutboundMessage.Send( message )
See Also
� OutboundMessage.Create
� OutboundMessage.Send
� OutboundMessage.Writelnt32
OutboundMessage.Send
Brief
Sends the OutboundMessage.
Definition
OutboundMessage.Send( OutboundMessage msg, string personld = nil )
Arguments
msg - The instance of the message to send.personld - The person ID to send the message to. If it is not specified the message is sent to all
clients.
Return Values
None.
Description
Sends the specified OutboundMessage. The message can be sent to a specific person or broadcast to all persons located in the current scene.
Examples
! local message = OutboundMessage.Create( 0, 6 )
I OutboundMessage.Writelntl6( message, index )
| OutboundMessage.Writelnt32( message, score )
j personld = Person.GetId( otherPerson )
j OutboundMessage.Send( message, personld )
See Also
None
OutboundMessage.Sendllnguaranteed
Brief
Sends the OutboundMessage over UDP.
Definition
OutboundMessage.SendUnguaranteed( OutboundMessage msg, string personld = nil )
Arguments
msg - The instance of the message to send.personld - The person ID to send the message to. If it is not specified the message is sent to all
clients.
Return Values
None.
Description
Sends the specified OutboundMessage. The message can be sent to a specific person or broadcast to all persons located in the current scene.
Please note that UDP messages are unguaranteed, out-of-order. Care must be taken when using this transport type as it is not suitable for all
message. Do not use this if your message must reach the target user. If ordering is essential, this can be achieved by simply adding a time stamp
to the message and manually checking and discarding out-of-order messages on the receiving side. The global function GetlnstanceTime can be
used as one method of manually adding a timestamp.
Examples
local message = OutboundMessage.Create( 0, 6 )
OutboundMessage.Writelnt16( message, index )
OutboundMessage.Writelnt32( message, score )
personld = Person.GetId( otherPerson )
OutboundMessage.SendUnguaranteed( message, personld )
See Also
� GetlnstanceTime
� OutboundMessage.Send
OutboundMessage.WriteBiglnt
Brief
Write a Biglnt value into an outbound message.
Definition
OutboundMessage.WriteBiglnt( OutboundMessage msg, Biglnt biglnt )
Arguments
msg - The message.biglnt - The Biglnt value to write.
Return Values
None.
Description
Writes a Biglnt value into an outbound message. Any size of Biglnt is permissible.
Examples
local message = OutboundMessage.Create(0, 8 )
local biglnt = Biglnt.Create(64, "0xl234567890ABCDEF")
OutboundMessage.WriteBiglnt( message, biglnt )
OutboundMessage.Send( message )
See Also
� Biglnt.Create
OutboundMessage.WriteFloat
Brief
Writes a 32-bit floating point value (float) to the message.
Definition
OutboundMessage.WriteFloat( OutboundMessage msg, number data )
Arguments
msg - The instance of the message to write to.data - 32-bit floating point value to write to the message packet.
Return Values
None.
Description
Writes a 32-bit floating point value (float) to the message.
Examples
local message = OutboundMessage.Create( 0, 4 )
OutboundMessage.WriteFloat( message, 3.14159 )
OutboundMessage.Send( message )
See Also
� OutboundMessage.Writelnt8
� OutboundMessage. Writelntl 6
� OutboundMessage. Writelnt32
� OutboundMessage.WriteString
OutboundMessage.Writelnt8
Brief
Writes an 8-bit integer to the message.
Definition
OutboundMessage.Writelnt8( OutboundMessage msg, number data )
Arguments
msg - The instance of the message to write to.data - 8-bit integer to write to the message packet.
Return Values
None.
Description
Writes an 8-bit integer (or byte) to the message.
Examples
local message = OutboundMessage.Create( 0, 1 )
OutboundMessage.Writelnt8( message, value )
OutboundMessage.Send( message )
See Also
� OutboundMessage.Writelnt16
� OutboundMessage.Writelnt32
� OutboundMessage.WriteFloat
� OutboundMessage.WriteString
OutboundMessage.Writelntl 6
Brief
Writes a 16-bit integer (short) to the message.
Definition
! OutboundMessage.Writelntl6( OutboundMessage msg, number data )
Arguments
msg - The instance of the message to write to.data - 16-bit integer to write to the message packet.
Return Values
None.
Description
Writes a 16-bit integer (short) to the message.
Examples
local message = OutboundMessage.Create( 0, 2 )
OutboundMessage.Writelntl6( message, index )
OutboundMessage.Send( message )
See Also
� OutboundMessage.Writelnt8
� OutboundMessage.Writelnt32
� OutboundMessage.WriteFloat
� OutboundMessage.WriteString
OutboundMessage.Writelnt32
Brief
Writes a 32-bit integer to the message.
Definition
OutboundMessage.Writelnt32( OutboundMessage msg, number data )
Arguments
msg - The instance of the message to write to.data - 32-bit integer to write to the message packet.
Return Values
None.
Description
Writes a 32-bit integer to the message.
Examples
local message = OutboundMessage.Create( 0, 4 )
OutboundMessage.Writelnt32( message, index )
OutboundMessage.Send( message )
See Also
� OutboundMessage. Writelnt8
� OutboundMessage. Writelntl 6
� OutboundMessage. WriteFloat
� OutboundMessage. WriteString
OutboundMessage.WriteString
Brief
Writes a string value to the message.
Definition
! OutboundMessage.WriteString( OutboundMessage msg, string data )
Arguments
msg - The instance of the message to write to.data - string value to write to the message packet.
Return Values
None.
Description
Writes a string value to the message.
Examples
greeting = "Hello World!"
� Msg size is length of string plus 1 for terminating character
msgSize = string.len( greeting ) + 1
local message = OutboundMessage.Create( 0, msgSize )
OutboundMessage.WriteString( message, greeting )
OutboundMessage.Send( message )
See Also
OutboundMessage. Writelnt8
OutboundMessage.Writelntl 6
OutboundMessage.Writelnt32
OutboundMessage.WriteFloat