Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions Runtime/Client.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Sockets;
using System.Collections.Generic;
using System.Collections;
Expand All @@ -10,6 +10,7 @@
using System.Security.Cryptography.X509Certificates;
using System.Security.Authentication;
using System.IO;
using UnityEngine.Events;

namespace Sand
{
Expand All @@ -36,6 +37,7 @@ public class Client : MonoBehaviour
public bool useTLS = false;
public bool leaveInnerStreamOpen = false;
public bool validateCert = true;
public UnityEvent sandReadingException = new UnityEvent();
private string eventDelimiter = "#e#";
private string packetDelimiter = "\n";

Expand Down Expand Up @@ -70,6 +72,25 @@ public void Connect()
}
}

public void Disconnect()
{
try
{
if (queueReadingRoutine != null)
StopCoroutine(queueReadingRoutine);

if (clientReceiveThread != null)
clientReceiveThread.Abort();

if (socketConnection != null)
socketConnection.Close();
}
catch (Exception ex)
{
Debug.LogError("Disconnecting Client Failed.");
}
}

private IEnumerator ReadingQueuedMessages()
{
while (true)
Expand Down Expand Up @@ -112,9 +133,10 @@ private void Reading()
}
}
}
catch (SocketException socketException)
{
Debug.LogError("Socket exception: " + socketException);
catch(Exception e)
{
Debug.LogError("Sand Reading Exception");
sandReadingException.Invoke();
}
}

Expand Down
5 changes: 3 additions & 2 deletions Runtime/com.ccadori.sandsocketunity.Runtime.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"WSA",
"WindowsStandalone32",
"WindowsStandalone64",
"XboxOne"
"XboxOne",
"LinuxStandalone64"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
Expand All @@ -18,4 +19,4 @@
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.ccadori.sandsocketunity",
"version": "1.0.1",
"version": "1.0.3",
"displayName": "Sand Socket Unity",
"unity": "2019.3",
"keywords": [
Expand Down