Skip to content

Commit

Permalink
Fixed a couple of compiler warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
yallie committed Nov 28, 2024
1 parent 426a649 commit 7498c1e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CoreRemoting/Channels/Websocket/WebsocketClientChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ await WebSocket.CloseAsync(WebSocketCloseStatus.NormalClosure,
LastException = ex as NetworkException ??
new NetworkException(ex.Message, ex);

ErrorOccured?.Invoke(ex.Message, ex);
Disconnected?.Invoke();
}
finally
Expand All @@ -169,6 +170,8 @@ public bool SendMessage(byte[] rawMessage)
{
LastException = ex as NetworkException ??
new NetworkException(ex.Message, ex);

ErrorOccured?.Invoke(ex.Message, ex);
return false;
}
}
Expand Down
11 changes: 6 additions & 5 deletions CoreRemoting/Channels/Websocket/WebsocketConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public WebsocketConnection(HttpListenerWebSocketContext websocketContext, WebSoc
RemotingServer = remotingServer ?? throw new ArgumentNullException(nameof(remotingServer));
}

public Guid Guid { get; } = Guid.NewGuid();

private HttpListenerWebSocketContext WebSocketContext { get; set; }

private WebSocket WebSocket { get; set; }
Expand Down Expand Up @@ -74,16 +72,17 @@ public bool SendMessage(byte[] rawMessage)
/// <summary>
/// Starts listening to the incoming messages.
/// </summary>
public void StartListening()
public Guid StartListening()
{
CreateRemotingSession();
var sessionId = CreateRemotingSession();
_ = ReadIncomingMessages();
return sessionId;
}

/// <summary>
/// Creates <see cref="RemotingSession"/> for the incoming websocket connection.
/// </summary>
private void CreateRemotingSession()
private Guid CreateRemotingSession()
{
byte[] clientPublicKey = null;

Expand All @@ -98,6 +97,8 @@ private void CreateRemotingSession()

Session = RemotingServer.SessionRepository.CreateSession(
clientPublicKey, RemotingServer, this);

return Session.SessionId;
}

private async Task ReadIncomingMessages()
Expand Down
4 changes: 2 additions & 2 deletions CoreRemoting/Channels/Websocket/WebsocketServerChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ private async Task ReceiveConnection()
var connection = new WebsocketConnection(websocketContext, websocket, Server);

// handle incoming websocket messages
Connections[connection.Guid] = connection;
connection.StartListening();
var sessionId = connection.StartListening();
Connections[sessionId] = connection;
}

/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion CoreRemoting/CoreRemoting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<PackageReference Include="WatsonTcp" Version="6.0.6" />
<PackageReference Include="websocketsharp.core" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<Protobuf Include="**/*.proto" />
</ItemGroup>
Expand Down

0 comments on commit 7498c1e

Please sign in to comment.