-
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.
Add a new thread for message sending due to web socket requirements (#…
…140)
- Loading branch information
Showing
4 changed files
with
266 additions
and
129 deletions.
There are no files selected for viewing
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,30 @@ | ||
using Paranext.DataProvider.Messages; | ||
|
||
namespace Paranext.DataProvider.MessageHandlers; | ||
|
||
/// <summary> | ||
/// Handler for "Response" messages | ||
/// </summary> | ||
internal class MessageHandlerInitClient : IMessageHandler | ||
{ | ||
Action<int> _clientIdCallback; | ||
|
||
public MessageHandlerInitClient(Action<int> clientIdCallback) | ||
{ | ||
_clientIdCallback = clientIdCallback; | ||
} | ||
|
||
public IEnumerable<Message> HandleMessage(Message message) | ||
{ | ||
if (message == null) | ||
throw new ArgumentNullException(nameof(message)); | ||
|
||
if (message.Type != MessageType.InitClient) | ||
throw new ArgumentException("Incorrect message type", nameof(message)); | ||
|
||
var initClientMsg = (MessageInitClient)message; | ||
int clientId = initClientMsg.ConnectorInfo.ClientId; | ||
_clientIdCallback(clientId); | ||
yield return new MessageClientConnect(clientId); | ||
} | ||
} |
Oops, something went wrong.