Sending Data Through the VRee Platform

Sending data through the VRee Platform is done by creating your own packets that override from EasyHandlerBaseClientToServer or EasyHandlerBaseServerToClient. Let’s take a look at some example code. In this example, we’ll be sending an Integer to the client(s) using the EasyHandlerBaseServerToClient.

On the server side, we’ll first create the packet by overriding the EasyHandlerBaseServerToClient. The recommended file structure can be seen in the figure below.

When overriding the EasyHandlerBaseServerToClient class, ensure that the given types are correct. In this example packet handler, we simply print the Integer. The OnReceive method from this client sided packet will only be called when receiving the ExamplePacket on the client side.

Now on the server, we simply send the packet by calling the SendToAll() method of the packet as shown in the figure below. The Send() method on a ServerToClient packet sends the packet to a specific client with the given ID.

Attaching this SendExamplePacket script to a GameObject will send two packets to the client when a client connects. On the client side, the following debug lines are logged:

Received 0 from server.
Received 1 from server.