Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ChzzkChat v1.0.1
ChzzkChat.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Authentication; using System.Security.Permissions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChzzkChat.Configuration; using ChzzkChat.chzzk; using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks.CompilerServices; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using WebSocketSharp; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ChzzkChat")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A template for Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7f7c516894c4cca05a8fc494878ac94e8883e916")] [assembly: AssemblyProduct("ChzzkChat")] [assembly: AssemblyTitle("ChzzkChat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalCompanyTemplate { public static class PluginInfo { public const string PLUGIN_GUID = "ChzzkChat"; public const string PLUGIN_NAME = "ChzzkChat"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ChzzkChat { [BepInPlugin("ChzzkChat", "ChzzkChat", "0.0.1")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("ChzzkChat"); private static string[] colors = new string[14] { "#f4dbd6", "#f0c6c6", "#f5bde6", "#c6a0f6", "#ed8796", "#ee99a0", "#f5a97f", "#eed49f", "#a6da95", "#8bd5ca", "#91d7e3", "#7dc4e4", "#8aadf4", "#b7bdf8" }; private static int colorIDX = 0; internal static ManualLogSource logger; private ChzzkUnity chzzkUnity; private void Awake() { harmony.PatchAll(); logger = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ChzzkChat is loaded!"); Config.Load(); ((MonoBehaviour)this).StartCoroutine(ReconnectCoroutine()); } private IEnumerator ReconnectCoroutine() { while (true) { yield return (object)new WaitForSeconds(1f); Debug.Log((object)$"{chzzkUnity}"); if ((Object)(object)chzzkUnity == (Object)null || chzzkUnity.connected == -1) { GameObject go = new GameObject("ChzzkUnity"); chzzkUnity = go.AddComponent<ChzzkUnity>(); chzzkUnity.onMessage.AddListener((UnityAction<ChzzkUnity.Profile, string>)delegate(ChzzkUnity.Profile profile, string msg) { ShowMessage(profile.nickname, msg); }); chzzkUnity.onDonation.AddListener((UnityAction<ChzzkUnity.Profile, string, ChzzkUnity.DonationExtras>)delegate(ChzzkUnity.Profile profile, string msg, ChzzkUnity.DonationExtras won) { ShowDotate(profile.nickname, won.payAmount.ToString(), msg); }); chzzkUnity.Connect(Config.ConfigChannelId); } } } public static void ShowMessage(string name, string msg) { try { string item = "<color=" + colors[colorIDX++] + ">" + name + "</color>: <color=#FFFFFF>" + msg + "</color>"; if (colorIDX >= colors.Length) { colorIDX = 0; } if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.ChatMessageHistory.Add(item); if (HUDManager.Instance.ChatMessageHistory.Count > 30) { HUDManager.Instance.ChatMessageHistory.RemoveAt(0); } ((TMP_Text)HUDManager.Instance.chatText).text = string.Join("\n", HUDManager.Instance.ChatMessageHistory); HUDManager.Instance.PingHUDElement(HUDManager.Instance.Chat, 2f, 1f, 0.2f); } } catch (Exception ex) { ManualLogSource obj = logger; if (obj != null) { obj.LogError((object)("Error showing message: " + ex.Message)); } } } public static void ShowDotate(string name, string won, string msg) { try { if (colorIDX >= colors.Length) { colorIDX = 0; } if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip(name + "님이 " + won + "원 후원하셨어요!", "<size=8>$" + msg + "</size>", false, false, "LC_Tip1"); HUDManager.Instance.PingHUDElement(HUDManager.Instance.Chat, 2f, 1f, 0.2f); } } catch (Exception ex) { ManualLogSource obj = logger; if (obj != null) { obj.LogError((object)("Error showing dotate: " + ex.Message)); } } } } } namespace ChzzkChat.chzzk { public class ChzzkUnity : MonoBehaviour { private enum SslProtocolsHack { Tls = 192, Tls11 = 768, Tls12 = 3072 } [Serializable] public class LiveStatus { [Serializable] public class Content { public string liveTitle; public string status; public int concurrentUserCount; public int accumulateCount; public bool paidPromotion; public bool adult; public string chatChannelId; public string categoryType; public string liveCategory; public string liveCategoryValue; public string livePollingStatusJson; public string faultStatus; public string userAdultStatus; public bool chatActive; public string chatAvailableGroup; public string chatAvailableCondition; public int minFollowerMinute; } public int code; public string message; public Content content; } [Serializable] public class AccessTokenResult { [Serializable] public class Content { [Serializable] public class TemporaryRestrict { public bool temporaryRestrict; public int times; public int duration; public int createdTime; } public string accessToken; public bool realNameAuth; public string extraToken; } public int code; public string message; public Content content; } [Serializable] public class Profile { [Serializable] public class StreamingProperty { } public string userIdHash; public string nickname; public string profileImageUrl; public string userRoleCode; public string badge; public string title; public string verifiedMark; public List<string> activityBadges; public StreamingProperty streamingProperty; } [Serializable] public class SubscriptionExtras { public int month; public string tierName; public string nickname; public int tierNo; } [Serializable] public class DonationExtras { [Serializable] public class WeeklyRank { public string userIdHash; public string nickName; public bool verifiedMark; public int donationAmount; public int ranking; } private object emojis; public bool isAnonymous; public string payType; public int payAmount; public string streamingChannelId; public string nickname; public string osType; public string donationType; public List<WeeklyRank> weeklyRankList; public WeeklyRank donationUserWeeklyRank; } [Serializable] public class ChannelInfo { [Serializable] public class Content { public string channelId; public string channelName; public string channelImageUrl; public bool verifiedMark; public string channelType; public string channelDescription; public int followerCount; public bool openLive; } public int code; public string message; public Content content; } [CompilerGenerated] private sealed class <Connect>d__29 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public ChzzkUnity <>4__this; private LiveStatus <liveStatus>5__1; private AccessTokenResult <accessTokenResult>5__2; private SslProtocols <sslProtocolHack>5__3; private LiveStatus <>s__4; private AccessTokenResult <>s__5; private Awaiter<LiveStatus> <>u__1; private Awaiter<AccessTokenResult> <>u__2; private Awaiter <>u__3; private void MoveNext() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { Awaiter<LiveStatus> awaiter3; Awaiter<AccessTokenResult> awaiter2; Awaiter awaiter; switch (num) { default: if (<>4__this.socket != null && <>4__this.socket.IsAlive) { <>4__this.socket.Close(); <>4__this.socket = null; } awaiter3 = <>4__this.GetLiveStatus(<>4__this.channel).GetAwaiter(); if (!awaiter3.IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter3; <Connect>d__29 <Connect>d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<LiveStatus>, <Connect>d__29>(ref awaiter3, ref <Connect>d__); return; } goto IL_00da; case 0: awaiter3 = <>u__1; <>u__1 = default(Awaiter<LiveStatus>); num = (<>1__state = -1); goto IL_00da; case 1: awaiter2 = <>u__2; <>u__2 = default(Awaiter<AccessTokenResult>); num = (<>1__state = -1); goto IL_0185; case 2: { awaiter = <>u__3; <>u__3 = default(Awaiter); num = (<>1__state = -1); break; } IL_0185: <>s__5 = awaiter2.GetResult(); <accessTokenResult>5__2 = <>s__5; <>s__5 = null; <>4__this.token = <accessTokenResult>5__2.content.accessToken; <>4__this.socket = new WebSocket("wss://kr-ss3.chat.naver.com/chat", Array.Empty<string>()); <sslProtocolHack>5__3 = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12; <>4__this.socket.SslConfiguration.EnabledSslProtocols = <sslProtocolHack>5__3; <>4__this.socket.OnMessage += <>4__this.ParseMessage; <>4__this.socket.OnClose += <>4__this.CloseConnect; <>4__this.socket.OnOpen += <>4__this.StartChat; <>4__this.socket.Connect(); awaiter = ((UniTask)(ref UniTask.CompletedTask)).GetAwaiter(); if (!((Awaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 2); <>u__3 = awaiter; <Connect>d__29 <Connect>d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <Connect>d__29>(ref awaiter, ref <Connect>d__); return; } break; IL_00da: <>s__4 = awaiter3.GetResult(); <liveStatus>5__1 = <>s__4; <>s__4 = null; <>4__this.cid = <liveStatus>5__1.content.chatChannelId; awaiter2 = <>4__this.GetAccessToken(<>4__this.cid).GetAwaiter(); if (!awaiter2.IsCompleted) { num = (<>1__state = 1); <>u__2 = awaiter2; <Connect>d__29 <Connect>d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<AccessTokenResult>, <Connect>d__29>(ref awaiter2, ref <Connect>d__); return; } goto IL_0185; } ((Awaiter)(ref awaiter)).GetResult(); } catch (Exception exception) { <>1__state = -2; <liveStatus>5__1 = null; <accessTokenResult>5__2 = null; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; <liveStatus>5__1 = null; <accessTokenResult>5__2 = null; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [CompilerGenerated] private sealed class <GetAccessToken>d__28 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder<AccessTokenResult> <>t__builder; public string cid; public ChzzkUnity <>4__this; private string <url>5__1; private UnityWebRequest <request>5__2; private AccessTokenResult <accessTokenResult>5__3; private UnityWebRequestAsyncOperationAwaiter <>u__1; private void MoveNext() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; AccessTokenResult result; try { UnityWebRequestAsyncOperationAwaiter awaiter; if (num != 0) { <url>5__1 = "https://comm-api.game.naver.com/nng_main/v1/chats/access-token?channelId=" + cid + "&chatType=STREAMING"; <request>5__2 = UnityWebRequest.Get(<url>5__1); awaiter = UnityAsyncExtensions.GetAwaiter(<request>5__2.SendWebRequest()); if (!((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; <GetAccessToken>d__28 <GetAccessToken>d__ = this; <>t__builder.AwaitUnsafeOnCompleted<UnityWebRequestAsyncOperationAwaiter, <GetAccessToken>d__28>(ref awaiter, ref <GetAccessToken>d__); return; } } else { awaiter = <>u__1; <>u__1 = default(UnityWebRequestAsyncOperationAwaiter); num = (<>1__state = -1); } ((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).GetResult(); <accessTokenResult>5__3 = null; if ((int)<request>5__2.result == 1) { <accessTokenResult>5__3 = JsonUtility.FromJson<AccessTokenResult>(<request>5__2.downloadHandler.text); } result = <accessTokenResult>5__3; } catch (Exception exception) { <>1__state = -2; <url>5__1 = null; <request>5__2 = null; <accessTokenResult>5__3 = null; <>t__builder.SetException(exception); return; } <>1__state = -2; <url>5__1 = null; <request>5__2 = null; <accessTokenResult>5__3 = null; <>t__builder.SetResult(result); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [CompilerGenerated] private sealed class <GetChannelInfo>d__26 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder<ChannelInfo> <>t__builder; public string channelId; public ChzzkUnity <>4__this; private string <url>5__1; private UnityWebRequest <request>5__2; private ChannelInfo <channelInfo>5__3; private Awaiter<UnityWebRequest> <>u__1; private void MoveNext() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Invalid comparison between Unknown and I4 //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; ChannelInfo result; try { Awaiter<UnityWebRequest> awaiter; if (num != 0) { <url>5__1 = "https://api.chzzk.naver.com/service/v1/channels/" + channelId; <request>5__2 = UnityWebRequest.Get(<url>5__1); awaiter = UnityAsyncExtensions.ToUniTask(<request>5__2.SendWebRequest(), (IProgress<float>)null, (PlayerLoopTiming)8, default(CancellationToken), false).GetAwaiter(); if (!awaiter.IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; <GetChannelInfo>d__26 <GetChannelInfo>d__ = this; <>t__builder.AwaitUnsafeOnCompleted<Awaiter<UnityWebRequest>, <GetChannelInfo>d__26>(ref awaiter, ref <GetChannelInfo>d__); return; } } else { awaiter = <>u__1; <>u__1 = default(Awaiter<UnityWebRequest>); num = (<>1__state = -1); } awaiter.GetResult(); <channelInfo>5__3 = null; if ((int)<request>5__2.result == 1) { <channelInfo>5__3 = JsonUtility.FromJson<ChannelInfo>(<request>5__2.downloadHandler.text); } result = <channelInfo>5__3; } catch (Exception exception) { <>1__state = -2; <url>5__1 = null; <request>5__2 = null; <channelInfo>5__3 = null; <>t__builder.SetException(exception); return; } <>1__state = -2; <url>5__1 = null; <request>5__2 = null; <channelInfo>5__3 = null; <>t__builder.SetResult(result); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [CompilerGenerated] private sealed class <GetLiveStatus>d__27 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder<LiveStatus> <>t__builder; public string channelId; public ChzzkUnity <>4__this; private string <url>5__1; private UnityWebRequest <request>5__2; private LiveStatus <liveStatus>5__3; private UnityWebRequestAsyncOperationAwaiter <>u__1; private void MoveNext() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; LiveStatus result; try { UnityWebRequestAsyncOperationAwaiter awaiter; if (num != 0) { <url>5__1 = "https://api.chzzk.naver.com/polling/v2/channels/" + channelId + "/live-status"; <request>5__2 = UnityWebRequest.Get(<url>5__1); awaiter = UnityAsyncExtensions.GetAwaiter(<request>5__2.SendWebRequest()); if (!((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; <GetLiveStatus>d__27 <GetLiveStatus>d__ = this; <>t__builder.AwaitUnsafeOnCompleted<UnityWebRequestAsyncOperationAwaiter, <GetLiveStatus>d__27>(ref awaiter, ref <GetLiveStatus>d__); return; } } else { awaiter = <>u__1; <>u__1 = default(UnityWebRequestAsyncOperationAwaiter); num = (<>1__state = -1); } ((UnityWebRequestAsyncOperationAwaiter)(ref awaiter)).GetResult(); <liveStatus>5__3 = null; if ((int)<request>5__2.result == 1) { <liveStatus>5__3 = JsonUtility.FromJson<LiveStatus>(<request>5__2.downloadHandler.text); } result = <liveStatus>5__3; } catch (Exception exception) { <>1__state = -2; <url>5__1 = null; <request>5__2 = null; <liveStatus>5__3 = null; <>t__builder.SetException(exception); return; } <>1__state = -2; <url>5__1 = null; <request>5__2 = null; <liveStatus>5__3 = null; <>t__builder.SetResult(result); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } private const string WS_URL = "wss://kr-ss3.chat.naver.com/chat"; private const string HEARTBEAT_REQUEST = "{\"ver\":\"2\",\"cmd\":0}"; private const string HEARTBEAT_RESPONSE = "{\"ver\":\"2\",\"cmd\":10000}"; private string cid; private string token; public string channel; private WebSocket socket = null; private float timer = 0f; private bool running = false; public UnityEvent<Profile, string> onMessage = new UnityEvent<Profile, string>(); public UnityEvent<Profile, string, DonationExtras> onDonation = new UnityEvent<Profile, string, DonationExtras>(); public UnityEvent<Profile, SubscriptionExtras> onSubscription = new UnityEvent<Profile, SubscriptionExtras>(); public UnityEvent onClose = new UnityEvent(); public UnityEvent onOpen = new UnityEvent(); public int connected = 0; private bool reOpenTrying = false; public IEnumerator TryReOpen() { Debug.Log((object)"연결 제시도"); reOpenTrying = true; yield return (object)new WaitForSeconds(3f); if (!socket.IsAlive) { socket.Connect(); } reOpenTrying = false; } private void FixedUpdate() { if (running) { timer += Time.unscaledDeltaTime; if (timer > 15f) { socket.Send("{\"ver\":\"2\",\"cmd\":0}"); timer = 0f; } } } private void OnDestroy() { StopListening(); } private void DebugMessage(Profile profile, string str) { Debug.Log((object)("| [Message] " + profile.nickname + " - " + str)); } private void DebugDonation(Profile profile, string str, DonationExtras donation) { Debug.Log((object)(donation.isAnonymous ? $"| [Donation] 익명 - {str} - {donation.payAmount}/{donation.payType}" : $"| [Donation] {profile.nickname} - {str} - {donation.payAmount}/{donation.payType}")); } private void DebugSubscription(Profile profile, SubscriptionExtras subscription) { Debug.Log((object)$"| [Subscription] {profile.nickname} - {subscription.month}"); } public void RemoveAllOnMessageListener() { ((UnityEventBase)onMessage).RemoveAllListeners(); } public void RemoveAllOnDonationListener() { ((UnityEventBase)onDonation).RemoveAllListeners(); } public void RemoveAllOnSubscriptionListener() { ((UnityEventBase)onSubscription).RemoveAllListeners(); } [AsyncStateMachine(typeof(<GetChannelInfo>d__26))] [DebuggerStepThrough] public UniTask<ChannelInfo> GetChannelInfo(string channelId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) <GetChannelInfo>d__26 <GetChannelInfo>d__ = new <GetChannelInfo>d__26(); <GetChannelInfo>d__.<>t__builder = AsyncUniTaskMethodBuilder<ChannelInfo>.Create(); <GetChannelInfo>d__.<>4__this = this; <GetChannelInfo>d__.channelId = channelId; <GetChannelInfo>d__.<>1__state = -1; <GetChannelInfo>d__.<>t__builder.Start<<GetChannelInfo>d__26>(ref <GetChannelInfo>d__); return <GetChannelInfo>d__.<>t__builder.Task; } [AsyncStateMachine(typeof(<GetLiveStatus>d__27))] [DebuggerStepThrough] public UniTask<LiveStatus> GetLiveStatus(string channelId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) <GetLiveStatus>d__27 <GetLiveStatus>d__ = new <GetLiveStatus>d__27(); <GetLiveStatus>d__.<>t__builder = AsyncUniTaskMethodBuilder<LiveStatus>.Create(); <GetLiveStatus>d__.<>4__this = this; <GetLiveStatus>d__.channelId = channelId; <GetLiveStatus>d__.<>1__state = -1; <GetLiveStatus>d__.<>t__builder.Start<<GetLiveStatus>d__27>(ref <GetLiveStatus>d__); return <GetLiveStatus>d__.<>t__builder.Task; } [AsyncStateMachine(typeof(<GetAccessToken>d__28))] [DebuggerStepThrough] public UniTask<AccessTokenResult> GetAccessToken(string cid) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) <GetAccessToken>d__28 <GetAccessToken>d__ = new <GetAccessToken>d__28(); <GetAccessToken>d__.<>t__builder = AsyncUniTaskMethodBuilder<AccessTokenResult>.Create(); <GetAccessToken>d__.<>4__this = this; <GetAccessToken>d__.cid = cid; <GetAccessToken>d__.<>1__state = -1; <GetAccessToken>d__.<>t__builder.Start<<GetAccessToken>d__28>(ref <GetAccessToken>d__); return <GetAccessToken>d__.<>t__builder.Task; } [AsyncStateMachine(typeof(<Connect>d__29))] [DebuggerStepThrough] public UniTask Connect() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) <Connect>d__29 <Connect>d__ = new <Connect>d__29(); <Connect>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); <Connect>d__.<>4__this = this; <Connect>d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref <Connect>d__.<>t__builder)).Start<<Connect>d__29>(ref <Connect>d__); return ((AsyncUniTaskMethodBuilder)(ref <Connect>d__.<>t__builder)).Task; } public void Connect(string channelId) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) channel = channelId; UniTaskExtensions.Forget(Connect()); } public void StopListening() { if (socket != null) { socket.Close(); socket = null; } } private void ParseMessage(object sender, MessageEventArgs e) { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown try { IDictionary<string, object> dictionary = JsonConvert.DeserializeObject<IDictionary<string, object>>(e.Data); Debug.Log((object)e.Data); switch ((long)dictionary["cmd"]) { case 0L: socket.Send("{\"ver\":\"2\",\"cmd\":10000}"); timer = 0f; break; case 93101L: { JArray val = (JArray)dictionary["bdy"]; { foreach (JToken item in val) { JObject val2 = (JObject)item; string text = ((object)val2["profile"])?.ToString(); if (text != null) { text = text.Replace("\\", ""); Profile profile = JsonUtility.FromJson<Profile>(text); onMessage?.Invoke(profile, ((object)val2["msg"])?.ToString().Trim()); } } break; } } case 93102L: { JArray val = (JArray)dictionary["bdy"]; { JToken val3 = default(JToken); JToken val4 = default(JToken); foreach (JToken item2 in val) { JObject val2 = (JObject)item2; string text = ((object)val2["profile"]).ToString(); text = text.Replace("\\", ""); Profile profile = JsonUtility.FromJson<Profile>(text); int num = int.Parse(((object)val2["msgTypeCode"]).ToString()); string text2 = null; if (val2.TryGetValue("extra", ref val3)) { text2 = ((object)val3).ToString(); } else if (val2.TryGetValue("extras", ref val4)) { text2 = ((object)val4).ToString(); } text2 = text2.Replace("\\", ""); switch (num) { case 10: { DonationExtras donationExtras = JsonUtility.FromJson<DonationExtras>(text2); onDonation?.Invoke(profile, ((object)val2["msg"]).ToString(), donationExtras); break; } case 11: { SubscriptionExtras subscriptionExtras = JsonUtility.FromJson<SubscriptionExtras>(text2); onSubscription?.Invoke(profile, subscriptionExtras); break; } default: Debug.LogError((object)$"MessageTypeCode-{num} is not supported"); Debug.LogError((object)((object)val2).ToString()); break; } } break; } } case 10100L: { UnityEvent obj = onOpen; if (obj != null) { obj.Invoke(); } break; } } } catch (Exception ex) { Debug.LogError((object)ex.ToString()); } } private void CloseConnect(object sender, CloseEventArgs e) { Debug.LogError((object)"연결이 해제되었습니다"); Debug.Log((object)e.Reason); Debug.Log((object)e.Code); Debug.Log((object)e); connected = -1; } private void StartChat(object sender, EventArgs e) { connected = 1; Debug.Log((object)("OPENED : " + cid + " + " + token)); string text = "{\"ver\":\"2\",\"cmd\":100,\"svcid\":\"game\",\"cid\":\"" + cid + "\",\"bdy\":{\"uid\":null,\"devType\":2001,\"accTkn\":\"" + token + "\",\"auth\":\"READ\"},\"tid\":1}"; timer = 0f; running = true; socket.Send(text); } } } namespace ChzzkChat.Configuration { internal static class Config { private static ConfigFile config; private static ConfigEntry<string> config_channel_id; public static string ConfigChannelId => config_channel_id.Value; public static void Load() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown string text = Path.Combine(Paths.ConfigPath, "ChzzkChat.cfg"); config = new ConfigFile(text, true); InternalLoad(); } public static void InternalLoad() { config_channel_id = config.Bind<string>("Access", "ChannelId", "", "Channel ID for chat"); } } }