Transferring variables using network library

I am making a game in which there I need several variables to be transferred from the client to the server and vice-versa.

This also involves variables located in a class.

I have made the game work in on a single project but would like to add a multiplayer.

The variables to be sent to the server is the key variable from 2 separate clients controlling different players.

xPos and yPos, xPos2, yPos2, and mode need to be sent to both clients.

Any help?
(Will include GitHub link soon)

1 Like

check out what we used here:
Convert JSON String to JSON Object and Parse all data - #4 by kll ,
websocket server client setup, lib /* Websockets 0.1b Lasse Steenbock Vestergaard */
transport a JSON record

here play again to confirm:

win 10 / processing 3.5.3 /
client server same computer ( 2 sketch running )

1 Like

Hi, how would I read the data and place it into variables? I get most of it but not how to read the data.

Hello,

The Processing SharedCanvasClient and SharedCanvasServer examples can be adapted for this:

image

I just added data (1 and 2) to identify each client (1 or 2) and checked for that on server to set color of line.

:slight_smile:

3 Likes