Initial commit
This commit is contained in:
41
Patches/EventPatch.cs
Normal file
41
Patches/EventPatch.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using ExitGames.Client.Photon;
|
||||
using HarmonyLib;
|
||||
using Newtonsoft.Json;
|
||||
using Photon.Realtime;
|
||||
using PhotonLogger.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
[HarmonyPatch]
|
||||
public class OnEventPatch
|
||||
{
|
||||
[Serializable]
|
||||
public class SerializableEventData
|
||||
{
|
||||
public byte Code { get; set; }
|
||||
public NonAllocDictionary<byte, object> Parameters { get; set; }
|
||||
}
|
||||
|
||||
static MethodInfo TargetMethod() => typeof(LoadBalancingClient).GetRuntimeMethod("OnEvent", [ typeof(EventData) ]);
|
||||
|
||||
static void Postfix(ref EventData photonEvent)
|
||||
{
|
||||
var newMsg = new Message
|
||||
{
|
||||
Time = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
|
||||
Type = MessageType.Event,
|
||||
Data = new SerializableEventData
|
||||
{
|
||||
Code = photonEvent.Code,
|
||||
Parameters = photonEvent.Parameters.paramDict
|
||||
}
|
||||
};
|
||||
|
||||
SocketProvider.Instance.Write(JsonConvert.SerializeObject(newMsg, Formatting.Indented, new JsonSerializerSettings
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user