MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / Send

Method Send

sdks/csharp/src/WebSocket.cs:466–487  ·  view source on GitHub ↗

This sender guarantees that that messages are sent out in the order they are received. Our websocket library only allows us to await one send call, so we have to wait until the current send call is complete before we start another one. This function is also thread safe, just in case. The message to send

(ClientMessage message)

Source from the content-addressed store, hash-verified

464 /// </summary>
465 /// <param name="message">The message to send</param>
466 public void Send(ClientMessage message)
467 {
468#if UNITY_WEBGL && !UNITY_EDITOR
469 try
470 {
471 var messageBSATN = new ClientMessage.BSATN();
472 var encodedMessage = IStructuralReadWrite.ToBytes(messageBSATN, message);
473 WebSocket_Send(_webglSocketId, encodedMessage, encodedMessage.Length);
474 }
475 catch (Exception e)
476 {
477 UnityEngine.Debug.LogError($"WebSocket send error: {e}");
478 dispatchQueue.Enqueue(() => OnSendError?.Invoke(e));
479 }
480#else
481 lock (messageSendQueue)
482 {
483 messageSendQueue.Enqueue(message);
484 senderTask ??= Task.Run(ProcessSendQueue);
485 }
486#endif
487 }
488
489 private async Task ProcessSendQueue()
490 {

Callers 9

InternalCallReducerMethod · 0.45
InternalCallProcedureMethod · 0.45
SubscribeMethod · 0.45
RemoteQueryMethod · 0.45
UnsubscribeMethod · 0.45
SendMessageMethod · 0.45
PostRequestMethod · 0.45
AskAiMethod · 0.45
UploadToS3Method · 0.45

Calls 1

ToBytesMethod · 0.45

Tested by

no test coverage detected