450 lines
14 KiB
C#
450 lines
14 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using BestHTTP.Futures;
|
|
using BestHTTP.SignalRCore;
|
|
using BestHTTP.SignalRCore.Encoders;
|
|
using BestHTTP.SignalRCore.Messages;
|
|
using Cpp2IlInjected;
|
|
using UnityEngine;
|
|
|
|
namespace BestHTTP.Examples
|
|
{
|
|
// Token: 0x020012CB RID: 4811
|
|
[Token(Token = "0x20012CB")]
|
|
[StructLayout(3)]
|
|
public class TestHubExample : MonoBehaviour
|
|
{
|
|
// Token: 0x06007885 RID: 30853 RVA: 0x00190A90 File Offset: 0x0018EC90
|
|
[Token(Token = "0x6007885")]
|
|
[Address(RVA = "0x1E69A10", Offset = "0x1E68410", VA = "0x181E69A10")]
|
|
private void Start()
|
|
{
|
|
HubOptions hubOptions = new HubOptions();
|
|
hubOptions.<SkipNegotiation>k__BackingField = false;
|
|
Uri uri = this.URI;
|
|
JsonProtocol jsonProtocol = new JsonProtocol(new LitJsonEncoder());
|
|
HubConnection hubConnection = new HubConnection(uri, jsonProtocol, hubOptions);
|
|
this.hub = hubConnection;
|
|
Action<HubConnection> action = new Action(this.Hub_OnConnected);
|
|
hubConnection.OnConnected += action;
|
|
HubConnection hubConnection2 = this.hub;
|
|
Action<HubConnection, string> action2 = new Action(this.Hub_OnError);
|
|
hubConnection2.OnError += action2;
|
|
HubConnection hubConnection3 = this.hub;
|
|
Action<HubConnection> action3 = new Action(this.Hub_OnClosed);
|
|
hubConnection3.OnClosed += action3;
|
|
HubConnection hubConnection4 = this.hub;
|
|
Func<HubConnection, Message, bool> func = new Func(this.Hub_OnMessage);
|
|
hubConnection4.OnMessage += func;
|
|
HubConnection hubConnection5 = this.hub;
|
|
Action<string> action4 = delegate(string arg)
|
|
{
|
|
string text = this.uiText;
|
|
string text2 = string.Format(" On Send: {0}\n", arg);
|
|
string text3 = text + text2;
|
|
this.uiText = text3;
|
|
};
|
|
hubConnection5.On<string>("Send", action4);
|
|
HubConnection hubConnection6 = this.hub;
|
|
Action<TestHubExample.Person> action5 = delegate(TestHubExample.Person person)
|
|
{
|
|
string text4 = this.uiText;
|
|
string text5 = string.Format(" On Person: {0}\n", person);
|
|
string text6 = text4 + text5;
|
|
this.uiText = text6;
|
|
};
|
|
hubConnection6.On<TestHubExample.Person>("Person", action5);
|
|
HubConnection hubConnection7 = this.hub;
|
|
Action<TestHubExample.Person, TestHubExample.Person> action6 = delegate(TestHubExample.Person person1, TestHubExample.Person person2)
|
|
{
|
|
string text7 = this.uiText;
|
|
string text8 = string.Format(" On TwoPersons: {0}, {1}\n", person1, person2);
|
|
string text9 = text7 + text8;
|
|
this.uiText = text9;
|
|
};
|
|
hubConnection7.On<TestHubExample.Person, TestHubExample.Person>("TwoPersons", action6);
|
|
this.hub.StartConnect();
|
|
this.uiText = "StartConnect called\n";
|
|
}
|
|
|
|
// Token: 0x06007886 RID: 30854 RVA: 0x00190BC8 File Offset: 0x0018EDC8
|
|
[Token(Token = "0x6007886")]
|
|
[Address(RVA = "0x1E65120", Offset = "0x1E63B20", VA = "0x181E65120")]
|
|
private void OnDestroy()
|
|
{
|
|
HubConnection hubConnection = this.hub;
|
|
if (hubConnection != 0)
|
|
{
|
|
hubConnection.StartClose();
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06007887 RID: 30855 RVA: 0x00190BE8 File Offset: 0x0018EDE8
|
|
[Token(Token = "0x6007887")]
|
|
[Address(RVA = "0x1E69960", Offset = "0x1E68360", VA = "0x181E69960")]
|
|
private void OnGUI()
|
|
{
|
|
Rect clientArea = GUIHelper.ClientArea;
|
|
Action action = delegate
|
|
{
|
|
GUILayoutOption[] array = Array.Empty<GUILayoutOption>();
|
|
Vector2 vector;
|
|
this.scrollPos = vector;
|
|
this.scrollPos.y = (float)0;
|
|
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
|
|
string text = this.uiText;
|
|
GUILayoutOption[] array2 = Array.Empty<GUILayoutOption>();
|
|
GUILayout.Label(text, array2);
|
|
GUILayout.EndVertical();
|
|
GUILayout.EndScrollView();
|
|
};
|
|
GUIHelper.DrawArea(clientArea, true, action);
|
|
}
|
|
|
|
// Token: 0x06007888 RID: 30856 RVA: 0x00190C10 File Offset: 0x0018EE10
|
|
[Token(Token = "0x6007888")]
|
|
[Address(RVA = "0x1E68B20", Offset = "0x1E67520", VA = "0x181E68B20")]
|
|
private void Hub_OnConnected(HubConnection hub)
|
|
{
|
|
string text = this.uiText + "Hub Connected\n";
|
|
this.uiText = text;
|
|
object[] array = new object[1];
|
|
if ("my message" != 0)
|
|
{
|
|
}
|
|
array[0] = "my message";
|
|
IFuture<bool> future = hub.Send("Send", array);
|
|
object[] array2 = Array.Empty<object>();
|
|
IFuture future2 = hub.Invoke<string>("NoParam", array2);
|
|
FutureValueCallback<string> futureValueCallback = delegate(string ret)
|
|
{
|
|
string text2 = this.uiText;
|
|
string text3 = string.Format(" 'NoParam' returned: {0}\n", ret);
|
|
string text4 = text2 + text3;
|
|
this.uiText = text4;
|
|
};
|
|
object[] array3 = new object[2];
|
|
int num;
|
|
if (num != 0)
|
|
{
|
|
}
|
|
array3[0] = num;
|
|
if (num != 0)
|
|
{
|
|
}
|
|
array3[1] = num;
|
|
IFuture future3 = hub.Invoke<int>("Add", array3);
|
|
FutureValueCallback<int> futureValueCallback2 = delegate(int result)
|
|
{
|
|
string text5 = this.uiText;
|
|
string text6 = string.Format(" 'Add(10, 20)' returned: {0}\n", result);
|
|
string text7 = text5 + text6;
|
|
this.uiText = text7;
|
|
};
|
|
FutureErrorCallback futureErrorCallback = delegate(Exception error)
|
|
{
|
|
string text8 = this.uiText;
|
|
string text9 = string.Format(" 'Add(10, 20)' error: {0}\n", error);
|
|
string text10 = text8 + text9;
|
|
this.uiText = text10;
|
|
};
|
|
object[] array4 = new object[2];
|
|
if ("Mr. Smith" != 0)
|
|
{
|
|
}
|
|
array4[0] = "Mr. Smith";
|
|
if ("Mr. Smith" != 0)
|
|
{
|
|
}
|
|
array4[1] = "Mr. Smith";
|
|
IFuture future4 = hub.Invoke<TestHubExample.Person>("GetPerson", array4);
|
|
FutureValueCallback<TestHubExample.Person> futureValueCallback3 = delegate(TestHubExample.Person result)
|
|
{
|
|
string text11 = this.uiText;
|
|
string text12 = string.Format(" 'GetPerson(\"Mr. Smith\", 26)' returned: {0}\n", result);
|
|
string text13 = text11 + text12;
|
|
this.uiText = text13;
|
|
};
|
|
int num2 = 0;
|
|
num2 += num2;
|
|
num2++;
|
|
FutureErrorCallback futureErrorCallback2 = delegate(Exception error)
|
|
{
|
|
string text14 = this.uiText;
|
|
string text15 = string.Format(" 'GetPerson(\"Mr. Smith\", 26)' error: {0}\n", error);
|
|
string text16 = text14 + text15;
|
|
this.uiText = text16;
|
|
};
|
|
object[] array5 = new object[2];
|
|
int num3;
|
|
if (num3 != 0)
|
|
{
|
|
num3 += 4;
|
|
num3 += 19;
|
|
}
|
|
array5[0] = num3;
|
|
if (num3 != 0)
|
|
{
|
|
}
|
|
array5[1] = num3;
|
|
IFuture future5 = hub.Invoke<int>("SingleResultFailure", array5);
|
|
FutureValueCallback<int> futureValueCallback4 = delegate(int result)
|
|
{
|
|
string text17 = this.uiText;
|
|
string text18 = string.Format(" 'SingleResultFailure(10, 20)' returned: {0}\n", result);
|
|
string text19 = text17 + text18;
|
|
this.uiText = text19;
|
|
};
|
|
FutureErrorCallback futureErrorCallback3 = delegate(Exception error)
|
|
{
|
|
string text20 = this.uiText;
|
|
string text21 = string.Format(" 'SingleResultFailure(10, 20)' error: {0}\n", error);
|
|
string text22 = text20 + text21;
|
|
this.uiText = text22;
|
|
};
|
|
object[] array6 = new object[1];
|
|
int num4;
|
|
if (num4 != 0)
|
|
{
|
|
}
|
|
array6[0] = num4;
|
|
IFuture future6 = hub.Invoke<int[]>("Batched", array6);
|
|
FutureValueCallback<int[]> futureValueCallback5 = delegate(int[] result)
|
|
{
|
|
string text23 = this.uiText;
|
|
int length = result.Length;
|
|
string text24 = string.Format(" 'Batched(10)' returned items: {0}\n", length);
|
|
string text25 = text23 + text24;
|
|
this.uiText = text25;
|
|
};
|
|
num2 += num2;
|
|
num2++;
|
|
FutureErrorCallback futureErrorCallback4 = delegate(Exception error)
|
|
{
|
|
string text26 = this.uiText;
|
|
string text27 = string.Format(" 'Batched(10)' error: {0}\n", error);
|
|
string text28 = text26 + text27;
|
|
this.uiText = text28;
|
|
};
|
|
object[] array7 = new object[2];
|
|
int num5;
|
|
if (num5 != 0)
|
|
{
|
|
num5 += 4;
|
|
num5 += 19;
|
|
}
|
|
array7[0] = num5;
|
|
if (num5 != 0)
|
|
{
|
|
}
|
|
array7[1] = num5;
|
|
IFuture future7 = hub.Stream<int>("ObservableCounter", array7);
|
|
FutureValueCallback<StreamItemContainer<int>> futureValueCallback6 = delegate(StreamItemContainer<int> result)
|
|
{
|
|
string text29 = this.uiText;
|
|
!0 <LastAdded>k__BackingField = result.<LastAdded>k__BackingField;
|
|
string text31;
|
|
string text30 = text29 + text31;
|
|
this.uiText = text30;
|
|
};
|
|
FutureValueCallback<StreamItemContainer<int>> futureValueCallback7 = delegate(StreamItemContainer<int> result)
|
|
{
|
|
string text32 = this.uiText;
|
|
int size = result.<Items>k__BackingField._size;
|
|
string text33 = string.Format(" 'ObservableCounter(10, 1000)' OnSuccess. Final count: {0}\n", size);
|
|
string text34 = text32 + text33;
|
|
this.uiText = text34;
|
|
};
|
|
FutureErrorCallback futureErrorCallback5 = delegate(Exception error)
|
|
{
|
|
string text35 = this.uiText;
|
|
string text36 = string.Format(" 'ObservableCounter(10, 1000)' error: {0}\n", error);
|
|
string text37 = text35 + text36;
|
|
this.uiText = text37;
|
|
};
|
|
object[] array8 = new object[2];
|
|
int num6;
|
|
if (num6 != 0)
|
|
{
|
|
}
|
|
array8[0] = num6;
|
|
if (num6 != 0)
|
|
{
|
|
}
|
|
array8[1] = num6;
|
|
IFuture future8 = hub.Stream<int>("ChannelCounter", array8);
|
|
FutureValueCallback<StreamItemContainer<int>> futureValueCallback8 = delegate(StreamItemContainer<int> result)
|
|
{
|
|
string text38 = this.uiText;
|
|
!0 <LastAdded>k__BackingField2 = result.<LastAdded>k__BackingField;
|
|
string text40;
|
|
string text39 = text38 + text40;
|
|
this.uiText = text39;
|
|
};
|
|
FutureValueCallback<StreamItemContainer<int>> futureValueCallback9 = delegate(StreamItemContainer<int> result)
|
|
{
|
|
string text41 = this.uiText;
|
|
int size2 = result.<Items>k__BackingField._size;
|
|
string text42 = string.Format(" 'ChannelCounter(10, 1000)' OnSuccess. Final count: {0}\n", size2);
|
|
string text43 = text41 + text42;
|
|
this.uiText = text43;
|
|
};
|
|
FutureErrorCallback futureErrorCallback6 = delegate(Exception error)
|
|
{
|
|
string text44 = this.uiText;
|
|
string text45 = string.Format(" 'ChannelCounter(10, 1000)' error: {0}\n", error);
|
|
string text46 = text44 + text45;
|
|
this.uiText = text46;
|
|
};
|
|
if (num2 < typeof(IFuture<StreamItemContainer<int>>).TypeHandle)
|
|
{
|
|
num2 += num2;
|
|
if (num2 == typeof(IFuture<StreamItemContainer<int>>).TypeHandle)
|
|
{
|
|
goto IL_2CE;
|
|
}
|
|
num2++;
|
|
}
|
|
hub.CancelStream<int>(num2);
|
|
object[] array9 = new object[2];
|
|
int num7;
|
|
if (num7 == 0)
|
|
{
|
|
goto IL_2E2;
|
|
}
|
|
IL_2CE:
|
|
num7 += num7;
|
|
num7++;
|
|
num7 += 19;
|
|
IL_2E2:
|
|
array9[0] = num7;
|
|
if (num7 != 0)
|
|
{
|
|
}
|
|
array9[1] = num7;
|
|
IFuture future9 = hub.Stream<TestHubExample.Person>("GetRandomPersons", array9);
|
|
FutureValueCallback<StreamItemContainer<TestHubExample.Person>> futureValueCallback10 = delegate(StreamItemContainer<TestHubExample.Person> result)
|
|
{
|
|
string text48;
|
|
string text47 = this.uiText + text48;
|
|
this.uiText = text47;
|
|
};
|
|
FutureValueCallback<StreamItemContainer<TestHubExample.Person>> futureValueCallback11 = delegate(StreamItemContainer<TestHubExample.Person> result)
|
|
{
|
|
string text49 = this.uiText;
|
|
int size3 = result.<Items>k__BackingField._size;
|
|
string text50 = string.Format(" 'GetRandomPersons(20, 1000)' OnSuccess. Final count: {0}\n", size3);
|
|
string text51 = text49 + text50;
|
|
this.uiText = text51;
|
|
};
|
|
}
|
|
|
|
// Token: 0x06007889 RID: 30857 RVA: 0x00190F4C File Offset: 0x0018F14C
|
|
[Token(Token = "0x6007889")]
|
|
[Address(RVA = "0x4405A0", Offset = "0x43EFA0", VA = "0x1804405A0")]
|
|
private bool Hub_OnMessage(HubConnection hub, Message message)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// Token: 0x0600788A RID: 30858 RVA: 0x00190F5C File Offset: 0x0018F15C
|
|
[Token(Token = "0x600788A")]
|
|
[Address(RVA = "0x1E68AD0", Offset = "0x1E674D0", VA = "0x181E68AD0")]
|
|
private void Hub_OnClosed(HubConnection hub)
|
|
{
|
|
string text = this.uiText + "Hub Closed\n";
|
|
this.uiText = text;
|
|
}
|
|
|
|
// Token: 0x0600788B RID: 30859 RVA: 0x00190F84 File Offset: 0x0018F184
|
|
[Token(Token = "0x600788B")]
|
|
[Address(RVA = "0x1E69900", Offset = "0x1E68300", VA = "0x181E69900")]
|
|
private void Hub_OnError(HubConnection hub, string error)
|
|
{
|
|
string text = this.uiText + "Hub Error: " + error + "\n";
|
|
this.uiText = text;
|
|
}
|
|
|
|
// Token: 0x0600788C RID: 30860 RVA: 0x00190FB0 File Offset: 0x0018F1B0
|
|
[Token(Token = "0x600788C")]
|
|
[Address(RVA = "0x1E6A7D0", Offset = "0x1E691D0", VA = "0x181E6A7D0")]
|
|
public TestHubExample()
|
|
{
|
|
Uri uri = new Uri(GUIHelper.BaseURL + "/TestHub");
|
|
this.URI = uri;
|
|
base..ctor();
|
|
}
|
|
|
|
// Token: 0x040056FC RID: 22268
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40056FC")]
|
|
private readonly Uri URI;
|
|
|
|
// Token: 0x040056FD RID: 22269
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40056FD")]
|
|
private HubConnection hub;
|
|
|
|
// Token: 0x040056FE RID: 22270
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x40056FE")]
|
|
private Vector2 scrollPos;
|
|
|
|
// Token: 0x040056FF RID: 22271
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x40056FF")]
|
|
private string uiText;
|
|
|
|
// Token: 0x020012CC RID: 4812
|
|
[Token(Token = "0x20012CC")]
|
|
private sealed class Person
|
|
{
|
|
// Token: 0x170013A2 RID: 5026
|
|
// (get) Token: 0x060078A2 RID: 30882 RVA: 0x00191438 File Offset: 0x0018F638
|
|
// (set) Token: 0x060078A3 RID: 30883 RVA: 0x0019144C File Offset: 0x0018F64C
|
|
[Token(Token = "0x170013A2")]
|
|
public string Name
|
|
{
|
|
[Token(Token = "0x60078A2")]
|
|
[Address(RVA = "0x3C39A0", Offset = "0x3C23A0", VA = "0x1803C39A0")]
|
|
get;
|
|
[Token(Token = "0x60078A3")]
|
|
[Address(RVA = "0x3C39B0", Offset = "0x3C23B0", VA = "0x1803C39B0")]
|
|
set;
|
|
}
|
|
|
|
// Token: 0x170013A3 RID: 5027
|
|
// (get) Token: 0x060078A4 RID: 30884 RVA: 0x00191460 File Offset: 0x0018F660
|
|
// (set) Token: 0x060078A5 RID: 30885 RVA: 0x00191474 File Offset: 0x0018F674
|
|
[Token(Token = "0x170013A3")]
|
|
public long Age
|
|
{
|
|
[Token(Token = "0x60078A4")]
|
|
[Address(RVA = "0x3C1240", Offset = "0x3BFC40", VA = "0x1803C1240")]
|
|
get;
|
|
[Token(Token = "0x60078A5")]
|
|
[Address(RVA = "0x3C1280", Offset = "0x3BFC80", VA = "0x1803C1280")]
|
|
set;
|
|
}
|
|
|
|
// Token: 0x060078A6 RID: 30886 RVA: 0x00191488 File Offset: 0x0018F688
|
|
[Token(Token = "0x60078A6")]
|
|
[Address(RVA = "0x1E67190", Offset = "0x1E65B90", VA = "0x181E67190", Slot = "3")]
|
|
public override string ToString()
|
|
{
|
|
long num = this.<Age>k__BackingField;
|
|
string text = this.<Name>k__BackingField;
|
|
return string.Format("[Person Name: '{0}', Age: {1}]", text, num);
|
|
}
|
|
|
|
// Token: 0x060078A7 RID: 30887 RVA: 0x001914B0 File Offset: 0x0018F6B0
|
|
[Token(Token = "0x60078A7")]
|
|
[Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")]
|
|
public Person()
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|