mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-14 11:48:28 -04:00
5e4b3bf490
* One-off query support (#49) * SpacetimeDBURI argument in place of host and ssl enabled bool (#52) * SpacetimeDBURI argument in place of host and ssl enabled bool * Small cleanup --------- Co-authored-by: John Detter <no-reply@boppygames.gg> * Add support for client address; re-run `spacetime generate` for quickstart client (#54) * README.md and License.txt updates (#53) * Update README.md * Add license.txt * Rename * Add LICENSE.txt with proper case --------- Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io> * Add support for client address; re-run `spacetime generate` for quickstart client Re: https://github.com/clockworklabs/SpacetimeDB/pull/299 --------- Co-authored-by: dbrinkmanncw <109690865+dbrinkmanncw@users.noreply.github.com> Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io> * Making Quickstart Work Again (#57) * Packaged nuget package, quickstart is now working again * Reset DBNAME --------- Co-authored-by: John Detter <no-reply@boppygames.gg> * OnUnhandledReducerError (#31) Co-authored-by: Steve <steve@codefics.com> Co-authored-by: Boppy <no-reply@boppygames.gg> --------- Co-authored-by: james gilles <jameshgilles@gmail.com> Co-authored-by: dbrinkmanncw <109690865+dbrinkmanncw@users.noreply.github.com> Co-authored-by: John Detter <no-reply@boppygames.gg> Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org> Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io> Co-authored-by: SteveBoytsun <100594800+SteveBoytsun@users.noreply.github.com> Co-authored-by: Steve <steve@codefics.com>
62 lines
2.0 KiB
C#
62 lines
2.0 KiB
C#
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
|
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
|
|
|
|
using System;
|
|
using ClientApi;
|
|
using Newtonsoft.Json.Linq;
|
|
using SpacetimeDB;
|
|
|
|
namespace SpacetimeDB.Types
|
|
{
|
|
public static partial class Reducer
|
|
{
|
|
public delegate void SendMessageHandler(ReducerEvent reducerEvent, string text);
|
|
public static event SendMessageHandler OnSendMessageEvent;
|
|
|
|
public static void SendMessage(string text)
|
|
{
|
|
var _argArray = new object[] {text};
|
|
var _message = new SpacetimeDBClient.ReducerCallRequest {
|
|
fn = "send_message",
|
|
args = _argArray,
|
|
};
|
|
SpacetimeDBClient.instance.InternalCallReducer(Newtonsoft.Json.JsonConvert.SerializeObject(_message, _settings));
|
|
}
|
|
|
|
[ReducerCallback(FunctionName = "send_message")]
|
|
public static bool OnSendMessage(ClientApi.Event dbEvent)
|
|
{
|
|
if(OnSendMessageEvent != null)
|
|
{
|
|
var args = ((ReducerEvent)dbEvent.FunctionCall.CallInfo).SendMessageArgs;
|
|
OnSendMessageEvent((ReducerEvent)dbEvent.FunctionCall.CallInfo
|
|
,(string)args.Text
|
|
);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
[DeserializeEvent(FunctionName = "send_message")]
|
|
public static void SendMessageDeserializeEventArgs(ClientApi.Event dbEvent)
|
|
{
|
|
var args = new SendMessageArgsStruct();
|
|
var bsatnBytes = dbEvent.FunctionCall.ArgBytes;
|
|
using var ms = new System.IO.MemoryStream();
|
|
ms.SetLength(bsatnBytes.Length);
|
|
bsatnBytes.CopyTo(ms.GetBuffer(), 0);
|
|
ms.Position = 0;
|
|
using var reader = new System.IO.BinaryReader(ms);
|
|
var args_0_value = SpacetimeDB.SATS.AlgebraicValue.Deserialize(SpacetimeDB.SATS.AlgebraicType.CreatePrimitiveType(SpacetimeDB.SATS.BuiltinType.Type.String), reader);
|
|
args.Text = args_0_value.AsString();
|
|
dbEvent.FunctionCall.CallInfo = new ReducerEvent(ReducerType.SendMessage, "send_message", dbEvent.Timestamp, Identity.From(dbEvent.CallerIdentity.ToByteArray()), Address.From(dbEvent.CallerAddress.ToByteArray()), dbEvent.Message, dbEvent.Status, args);
|
|
}
|
|
}
|
|
|
|
public partial class SendMessageArgsStruct
|
|
{
|
|
public string Text;
|
|
}
|
|
|
|
}
|