-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving Vicon DLLs to Assets/Plugins Adding back websockets
- Loading branch information
1 parent
a275cec
commit aa37dd8
Showing
103 changed files
with
1,701 additions
and
551 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
Assets/Scripts/WebSockets/Samples~/WebSocketExample/Connection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
using NativeWebSocket; | ||
|
||
public class Connection : MonoBehaviour | ||
{ | ||
WebSocket websocket; | ||
|
||
// Start is called before the first frame update | ||
async void Start() | ||
{ | ||
// websocket = new WebSocket("ws://echo.websocket.org"); | ||
websocket = new WebSocket("ws://localhost:3000"); | ||
|
||
websocket.OnOpen += () => | ||
{ | ||
Debug.Log("Connection open!"); | ||
}; | ||
|
||
websocket.OnError += (e) => | ||
{ | ||
Debug.Log("Error! " + e); | ||
}; | ||
|
||
websocket.OnClose += (e) => | ||
{ | ||
Debug.Log("Connection closed!"); | ||
}; | ||
|
||
websocket.OnMessage += (bytes) => | ||
{ | ||
// Reading a plain text message | ||
var message = System.Text.Encoding.UTF8.GetString(bytes); | ||
Debug.Log("Received OnMessage! (" + bytes.Length + " bytes) " + message); | ||
}; | ||
|
||
// Keep sending messages at every 0.3s | ||
InvokeRepeating("SendWebSocketMessage", 0.0f, 0.3f); | ||
|
||
await websocket.Connect(); | ||
} | ||
|
||
void Update() | ||
{ | ||
#if !UNITY_WEBGL || UNITY_EDITOR | ||
websocket.DispatchMessageQueue(); | ||
#endif | ||
} | ||
|
||
async void SendWebSocketMessage() | ||
{ | ||
if (websocket.State == WebSocketState.Open) | ||
{ | ||
// Sending bytes | ||
await websocket.Send(new byte[] { 10, 20, 30 }); | ||
|
||
// Sending plain text | ||
await websocket.SendText("plain text message"); | ||
} | ||
} | ||
|
||
private async void OnApplicationQuit() | ||
{ | ||
await websocket.Close(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Scripts/WebSockets/Samples~/WebSocketExample/Connection.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.