fix api test mod

This commit is contained in:
_nebula 2023-07-31 22:49:32 +01:00
parent c06d73db09
commit be23e80d51
2 changed files with 7 additions and 5 deletions

View File

@ -43,15 +43,15 @@ public class APITestMod : ModBehaviour
ModHelper.Console.WriteLine("Sending string message test...");
qsbAPI.RegisterHandler<string>("apitest-string", MessageHandler);
qsbAPI.SendMessage("apitest-string", "STRING MESSAGE", true);
qsbAPI.SendMessage("apitest-string", "STRING MESSAGE", receiveLocally: true);
ModHelper.Console.WriteLine("Sending int message test...");
qsbAPI.RegisterHandler<int>("apitest-int", MessageHandler);
qsbAPI.SendMessage("apitest-int", 123, true);
qsbAPI.SendMessage("apitest-int", 123, receiveLocally: true);
ModHelper.Console.WriteLine("Sending float message test...");
qsbAPI.RegisterHandler<float>("apitest-float", MessageHandler);
qsbAPI.SendMessage("apitest-float", 3.14f, true);
qsbAPI.SendMessage("apitest-float", 3.14f, receiveLocally: true);
});
};
}

View File

@ -1,4 +1,5 @@
using OWML.Common;
using System;
using OWML.Common;
using UnityEngine.Events;
public interface IQSBAPI
@ -58,8 +59,9 @@ public interface IQSBAPI
/// <typeparam name="T">The type of the data being sent. This type must be serializable.</typeparam>
/// <param name="messageType">The unique key of the message.</param>
/// <param name="data">The data to send.</param>
/// <param name="to">The player to send this message to. (0 is the host, uint.MaxValue means every player)</param>
/// <param name="receiveLocally">If true, the action given to <see cref="RegisterHandler{T}"/> will also be called on the same client that is sending the message.</param>
void SendMessage<T>(string messageType, T data, bool receiveLocally = false);
void SendMessage<T>(string messageType, T data, uint to = uint.MaxValue, bool receiveLocally = false);
/// <summary>
/// Registers an action to be called when a message is received.