Communication between Unity and the Frontend - refercene to code and added multiple coach approach authored by Birte Heinemann's avatar Birte Heinemann
This page details the process of sending information between the frontend (coach vr) and Unity. Communication occurs via web sockets in a (roughly) event-based manner (somewhat like Socket.IO, but due to lacking a correct server implementation on the Unity-side of things we're using bare web sockets instead). This page details sending information between the frontend (coach-vr) and Unity - you can find the code in another repository: https://gitup.uni-potsdam.de/wiepke/website-control. Communication occurs via web sockets in a (roughly) event-based manner (somewhat like Socket.IO, but due to lacking a correct server implementation on the Unity-side of things we're using bare web sockets instead).
## Basics ## Basics
...@@ -30,10 +30,17 @@ Below is a list of messages that (at time of writing) can be used to relegate da ...@@ -30,10 +30,17 @@ Below is a list of messages that (at time of writing) can be used to relegate da
* `classChange`, payload: `string` serialized object of shape `{room: string, front: string, outside: string, chairs: string, students: Number, messiness: Number, weather: WeatherPattern}`, where all of these fields may be optional * `classChange`, payload: `string` serialized object of shape `{room: string, front: string, outside: string, chairs: string, students: Number, messiness: Number, weather: WeatherPattern}`, where all of these fields may be optional
* `bootstrap`, payload: none. Request for Unity to send initial classroom info * `bootstrap`, payload: none. Request for Unity to send initial classroom info
* `behave`, payload: `{students: string[], behaviour: string}`. List of students and a behaviour to apply to them * `behave`, payload: `{students: string[], behaviour: string}`. List of students and behaviour to apply to them
* `askQuestion`, payload: `{students: string[], questions: Number[]}`. List of students and corresponding question ids * `askQuestion`, payload: `{students: string[], questions: Number[]}`. List of students and corresponding question ids
* `impulseGiven`, payload: `{students: string[], impulse: string}`. List of students to trigger impulse for * `impulseGiven`, payload: `{students: string[], impulse: string}`. List of students to trigger impulse for
* `themeChange`, payload: `{theme: string, skip: boolean, globalKnowledge: boolean}` * `themeChange`, payload: `{theme: string, skip: boolean, globalKnowledge: boolean}`
## Frontend (Coach VR)
## Multiple Coaches
We are working on a solution to give the possibility to connect more than one coach with Unity. This is a rough sketch.
For this, we use a new abstraction: rooms. Unity creates a new room when the participant enters a classroom. Coaches can join these within a one-to-many connection (multi-user).
Management and message flow are done via a central web service with a Socket.io base and uses simple communication protocol. For this, we revised the integration and use it event-based via Scriptable Objects.
![networking_08.2023](uploads/6becc53ec424e0fbc986ecb6d6337627/networking_08.2023.png)