File size: 15,970 Bytes
d7bb13e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | 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 |