PICO Platform Unity SDK
NetworkService Class Reference

Static Public Member Functions

static Packet ReadPacket ()
 Reads the messages from other users in the room.
 
static bool SendPacket (string userId, byte[] bytes)
 Sends messages to a specified user. The maximum messaging frequency is 1000/s. More...
 
static bool SendPacket (string userId, byte[] bytes, bool reliable)
 Sends messages to a specified user. The maximum messaging frequency is 1000/s. More...
 
static bool SendPacketToCurrentRoom (byte[] bytes)
 Sends messages to other users in the room. The maximum messaging frequency is 1000/s. More...
 
static bool SendPacketToCurrentRoom (byte[] bytes, bool reliable)
 Sends messages to other users in the room. The maximum messaging frequency is 1000/s. More...
 
static void SetPlatformGameInitializeAsynchronousCallback (Message< GameInitializeResult >.Handler handler)
 
static void SetNotification_Game_ConnectionEventCallback (Message< GameConnectionEvent >.Handler handler)
 Sets the callback to get notified when the game network fluctuates. Listen to this event to receive a relevant message. Use Message.Data to get the network situation in the game. More...
 
static void SetNotification_Game_Request_FailedCallback (Message< GameRequestFailedReason >.Handler handler)
 
static void SetNotification_Game_StateResetCallback (Message.Handler handler)
 Sets the callback to get notified when the game state needs to be reset. Listen to this event to receive a relevant message. If you receive this message, you will need to reset your gaming state. For example, More...
 

Member Function Documentation

◆ SendPacket() [1/2]

static bool SendPacket ( string  userId,
byte[]  bytes 
)
inlinestatic

Sends messages to a specified user. The maximum messaging frequency is 1000/s.

Parameters
userIdThe ID of the user to send messages to.
bytesThe message length (in bytes). The maximum bytes allowed is 512.
Returns
  • true: success
  • false: failure

◆ SendPacket() [2/2]

static bool SendPacket ( string  userId,
byte[]  bytes,
bool  reliable 
)
inlinestatic

Sends messages to a specified user. The maximum messaging frequency is 1000/s.

Parameters
userIdThe ID of the user to send messages to.
bytesThe message length (in bytes). The maximum bytes allowed is 512.
reliableWhen reliable is set to true, messages between lost and resume will not be lost. The retention time is determined by the reserve_period parameter configured for the matchmaking pool, with a maximum of 1 minute. When reliable is set to false, this function works the same as the other SendPacket function.
Returns
  • true: success
  • false: failure

◆ SendPacketToCurrentRoom() [1/2]

static bool SendPacketToCurrentRoom ( byte[]  bytes)
inlinestatic

Sends messages to other users in the room. The maximum messaging frequency is 1000/s.

Parameters
bytesThe message length (in bytes). The maximum bytes allowed is 512.
Returns
  • true: success
  • false: failure

◆ SendPacketToCurrentRoom() [2/2]

static bool SendPacketToCurrentRoom ( byte[]  bytes,
bool  reliable 
)
inlinestatic

Sends messages to other users in the room. The maximum messaging frequency is 1000/s.

Parameters
bytesThe message length (in bytes). The maximum bytes allowed is 512.
reliableWhen reliable is set to true, messages between lost and resume will not be lost. The retention time is determined by the reserve_period parameter configured for the matchmaking pool, with a maximum of 1 minute. When reliable is set to false, this function works the same as the other SendPacketToCurrentRoom function.
Returns
  • true: success
  • false: failure

◆ SetNotification_Game_ConnectionEventCallback()

static void SetNotification_Game_ConnectionEventCallback ( Message< GameConnectionEvent >.Handler  handler)
inlinestatic

Sets the callback to get notified when the game network fluctuates. Listen to this event to receive a relevant message. Use Message.Data to get the network situation in the game.

Parameters
handlerCallback handler. The callback function will be called when receiving the Notification_Game_ConnectionEvent message and the value of requestID is 0.

◆ SetNotification_Game_StateResetCallback()

static void SetNotification_Game_StateResetCallback ( Message.Handler  handler)
inlinestatic

Sets the callback to get notified when the game state needs to be reset. Listen to this event to receive a relevant message. If you receive this message, you will need to reset your gaming state. For example,

  • If you are in a room before receiving this message, you will need to check and reset your room state after receving this message.
  • If you are in a matchmaking queue before receiving this message, you will need to check and reset your matchmaking state after receiving this message.
Parameters
handlerCallback handler. The callback function will be called when receiving the "Notification_Game_StateReset" message and the value of requestID is 0.