diff --git a/Oxide.Ext.GamingApiTests/GamingApiNatsTests.cs b/Oxide.Ext.GamingApiTests/GamingApiNatsTests.cs index 2cb4171..89942a0 100644 --- a/Oxide.Ext.GamingApiTests/GamingApiNatsTests.cs +++ b/Oxide.Ext.GamingApiTests/GamingApiNatsTests.cs @@ -1,9 +1,12 @@ using Asyncapi.Nats.Client; using NATS.Client; +using NATS.Client.JetStream; using NUnit.Framework; using System; using System.Diagnostics; using System.IO; +using System.Text; +using System.Text.Json; using System.Threading; namespace Oxide.Ext.GamingApi.Tests @@ -58,5 +61,36 @@ public void replyToRustApiprocessServersServerIdEventsStartedTest() blackhawkNats.PublishToV0RustServersServerIdEventsStarted("101"); } + + + + [Test()] + public void randomTest() + { + Options opts = ConnectionFactory.GetDefaultOptions(); + + opts.Url = "nats://localhost:4222"; + EventHandler sigEh = (sender, args) => + { + // get a private key seed from your environment. + string seed = "SUAHZGQCK3PKMY5JBY2PBJUK2SA2IAGNX7VXYQJ75MLIU2IWQE235OBLJM"; + + // Generate a NkeyPair + NkeyPair kp = Nkeys.FromSeed(seed); + + // Sign the nonce and return the result in the SignedNonce + // args property. This must be set. + args.SignedNonce = kp.Sign(args.ServerNonce); + }; + opts.SetNkey("UCI2NCSIEV3DXLYYR5KQXYCZ7CIW4KYXHLSGXJOZ7TSRRKHP2BM5IVMU", sigEh); + var c = new ConnectionFactory().CreateConnection(opts); + IJetStream js = c.CreateJetStreamContext(); + var message = new Asyncapi.Nats.Client.Models.ChatMessage(); + message.PlayerName = "test"; + var json = JsonSerializer.Serialize(message); + var bytes = Encoding.UTF8.GetBytes(json); + js.Publish("v0.rust.servers.101.events.player.123.chatted", bytes); + } + } } \ No newline at end of file