Skip to content

Commit 9e5a77c

Browse files
committed
Moved all SessionSocketClient files inside folder. Updated README.
1 parent b21966d commit 9e5a77c

16 files changed

+57
-3
lines changed
File renamed without changes.
File renamed without changes.

Assets/SessionSocketClient/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Unity Session Socket Client
2+
3+
A Unity library for connecting, sending, and receiving with the [Session Socket Server](https://github.com/Blitzy/session-socket-server)
4+
5+
## Quick Start
6+
1. Launch and instance of the Session Socket Server and open up the Demo scene.
7+
2. Fill in the socket server's ip adress and port on the `DemoController` component.
8+
3. Indicator in top right corner should turn green and say "Connected" if connection was successful. If it does not connect, check the Unity console logs for debugging.
9+
4. Play with the on-screen controls in the Demo scene and notice how they persist even when you restart the game.
10+
11+
## The Components
12+
13+
### Session Socket Client
14+
15+
The Session Socket Client game object has three main components attached to it.
16+
17+
#### SocketManager
18+
The `SocketManager` contains all the functionality of connecting, sending, and receiving messages with/from the Session Socket Server.
19+
20+
#### SocketHeartbeat
21+
The `SocketHeartbeat` component watches the SocketManager's connection state and will send regular `KEEP` (Heartbeat) messages to the Session Socket Server to let it know that the client is still connected. If the server shuts down or connection is otherwise lost to the Sesssion Socket Server, `SocketHeartbeat` will automatically stop sending heartbeats.
22+
23+
#### SessionDataManager
24+
The `SessionDataManager` manages all of the session data on the client side from the Session Socket Server. It is the responsibility of SessionData objects to subscribe to it for updates and unsubscribe when no longer needed (like when being destroyed).
25+
26+
### Session Data
27+
28+
#### ISessionData
29+
The `ISessionData` interface is a generic interface that can be implemented by any class that wants to subscribe to updates from the `SessionDataManager`.
30+
31+
#### UnitySessionData
32+
`UnitySessionData` is an abstract class that inherits from `ISessionData` and handles SessionData in a very Unity-like way through MonoBehaviour components. There are a number of examples already written to show how to use `UnitySessionData` that you can check out.
33+
34+
The basic concept is that a `UnitySessionData` component is simply a MonoBehaviour component that acts as a data store for another object. It should listen for changes on that object and keep a copy of that object's data for itself. When data changes on the object the `UnitySessionData` component is designed to watch, it should save it locally and then run the `UnitySessionData.SaveData()` method in order to send it to the Session Socket Server.
35+
36+
> **NOTE:** `UnitySessionData` components save and update themselves using Unity's [JsonUtility](https://docs.unity3d.com/ScriptReference/JsonUtility.html) class. You should be familiar with how it works so that you make sure to only have data you actually want transfered over the server to be sent.
37+
38+
`UnitySessionData` has a number of methods that derived classes need to implement:
39+
40+
1. `Init()` - Use to initialize the session data component with other components it is designed to watch.
41+
2. `HookupEventListeners()` - Subscribe to events the session data cares about to modify its own data.
42+
3. `UnhookEventListeners()` - Unsubscribe from events the session data is listening to.
43+
4. `UpdateDataFromLocal()` - Use to update the session data stored in this component from the other components it watches.
44+
5. `UpdateLocalFromData()` - Use to update the watched components with the data stored in this component.

Assets/SessionSocketClient/README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

ProjectSettings/EditorBuildSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ EditorBuildSettings:
66
serializedVersion: 2
77
m_Scenes:
88
- enabled: 1
9-
path: Assets/Demo/Scenes/Demo.unity
9+
path: Assets/SessionSocketClient/Demo/Scenes/Demo.unity
1010
guid: 9fc0d4010bbf28b4594072e72b8655ab
1111
m_configObjects: {}

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# unity-session-socket-client
2-
A Unity library for connecting, sending, and receiving with the session-socket-server.
1+
# Unity Session Socket Client
2+
3+
A Unity library for connecting, sending, and receiving with the [Session Socket Server](https://github.com/Blitzy/session-socket-server)
4+
5+
For the full README for the library check it out [inside the actual library folder over here.](Assets/SessionSocketClient/README.md)

0 commit comments

Comments
 (0)