# Transferring variables using network library

**URL:** <https://discourse.processing.org/t/transferring-variables-using-network-library/14705>\
**Category:** Libraries\
**Created:** [October 15, 2019, 4:19am UTC](https://discourse.processing.org/t/transferring-variables-using-network-library/14705 "2019-10-15T04:19:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![111foxman111](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/111foxman111/32/6766_2.png) [@111foxman111](https://discourse.processing.org/u/111foxman111)\
**Post date:** [October 15, 2019, 4:19am UTC](https://discourse.processing.org/t/transferring-variables-using-network-library/14705/1 "2019-10-15T04:19:42Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 15, 2019, 9:49am UTC](https://discourse.processing.org/t/transferring-variables-using-network-library/14705/2 "2019-10-15T09:49:58Z")

</div>

check out what we used here:  
[Convert JSON String to JSON Object and Parse all data - #4 by kll](https://discourse.processing.org/t/convert-json-string-to-json-object-and-parse-all-data/10407/4) ,  
websocket server client setup, lib /\* Websockets 0.1b Lasse Steenbock Vestergaard \*/  
transport a JSON record

 ![websocket_server_client_JSON](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3dc5df8f409a660cb24b52004d8072c07217685d.png)

here play again to confirm:

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

---

<div class="post-metadata">

**Author:** ![111foxman111](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/111foxman111/32/6766_2.png) [@111foxman111](https://discourse.processing.org/u/111foxman111)\
**Post date:** [October 15, 2019, 4:06pm UTC](https://discourse.processing.org/t/transferring-variables-using-network-library/14705/3 "2019-10-15T16:06:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 15, 2019, 6:56pm UTC](https://discourse.processing.org/t/transferring-variables-using-network-library/14705/4 "2019-10-15T18:56:24Z")

</div>

Hello,

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

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/17a72e83fd9fbb7b4054741fa886f6d2dc1f738a.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/fcce654ab5a898160619d21d40b3e43703261d8d.png)

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.

🙂
