Skip to content
Merged
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
25 changes: 6 additions & 19 deletions Visual Studio Projects/ZWaveJS.NET/ZWaveJS.NET/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Driver
private Dictionary<string, Action<JObject>> NodeEventMap;
private Dictionary<string, Action<JObject>> ControllerEventMap;
private Dictionary<string, Action<JObject>> DriverEventMap;
private Semver.SemVersion SchemaVersionID = new Semver.SemVersion(1, 40, 0);
private int _schemaVersion = 42;
private string SerialPort;
private bool RequestedExit = false;
private JsonSerializer _jsonSerializer;
Expand Down Expand Up @@ -571,7 +571,7 @@ public Driver(Uri Server, int SchemaVersion = 0, int ServerErrorThrottleTime = 1

if (SchemaVersion > 0)
{
SchemaVersionID = new Semver.SemVersion(1, SchemaVersion, 0);
_schemaVersion = SchemaVersion;
}

Callbacks = new Dictionary<Guid, Action<JObject>>();
Expand Down Expand Up @@ -710,7 +710,7 @@ private void DestroySocket()
{
if (ClientWebSocket.IsRunning)
{
ClientWebSocket.Stop(WebSocketCloseStatus.NormalClosure, "Destroy");
_ = ClientWebSocket.Stop(WebSocketCloseStatus.NormalClosure, "Destroy");
}

if (Host)
Expand Down Expand Up @@ -768,7 +768,7 @@ private void SettleCallbacksError()
Callbacks[ID].Invoke(JO);
Callbacks.Remove(ID);
}
catch (Exception Error)
catch (Exception)
{
continue;
}
Expand Down Expand Up @@ -966,7 +966,7 @@ private void WebsocketClient_MessageReceived(object sender, ResponseMessage Mess
Callbacks[MessageID].Invoke(JO);
Callbacks.Remove(MessageID);
}
catch (Exception Error) { }
catch (Exception) { }

}

Expand All @@ -978,26 +978,13 @@ private void WebsocketClient_MessageReceived(object sender, ResponseMessage Mess
_ZWaveJSDriverVersion = JO.Value<string>("driverVersion");
_ZWaveJSServerVersion = JO.Value<string>("serverVersion");

if (Semver.SemVersion.Parse(_ZWaveJSServerVersion, Semver.SemVersionStyles.Strict).Major != SchemaVersionID.Major)
{
StartUpError?.Invoke("The Server Schema version is not compatible with the library version");
return;
}

if (Semver.SemVersion.Parse(_ZWaveJSServerVersion, Semver.SemVersionStyles.Strict).ComparePrecedenceTo(SchemaVersionID) < 0)
{
StartUpError?.Invoke("The Server Schema version is lower than what was requested by the library");
return;

}

Guid CBID = Guid.NewGuid();
Callbacks.Add(CBID, SetAPIVersionCB);

Dictionary<string, object> Request = new Dictionary<string, object>();
Request.Add("messageId", CBID.ToString());
Request.Add("command", Enums.Commands.SetAPIVersion);
Request.Add("schemaVersion", SchemaVersionID.Minor);
Request.Add("schemaVersion", _schemaVersion);

string RequestPL = Newtonsoft.Json.JsonConvert.SerializeObject(Request);

Expand Down