Files
Dec2017-Script-Dump/Photon3Unity3D/ExitGames/Client/Photon/PingMono.cs
T
2026-06-04 11:42:34 +02:00

88 lines
1.9 KiB
C#

using System;
using System.Net.Sockets;
namespace ExitGames.Client.Photon
{
// Token: 0x0200002A RID: 42
public class PingMono : PhotonPing
{
// Token: 0x06000214 RID: 532 RVA: 0x00011900 File Offset: 0x0000FB00
public override bool StartPing(string ip)
{
base.Init();
try
{
bool flag = ip.Contains(".");
if (flag)
{
this.sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
}
else
{
this.sock = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
}
this.sock.ReceiveTimeout = 5000;
this.sock.Connect(ip, 5055);
this.PingBytes[this.PingBytes.Length - 1] = this.PingId;
this.sock.Send(this.PingBytes);
this.PingBytes[this.PingBytes.Length - 1] = this.PingId - 1;
}
catch (Exception ex)
{
this.sock = null;
Console.WriteLine(ex);
}
return false;
}
// Token: 0x06000215 RID: 533 RVA: 0x000119DC File Offset: 0x0000FBDC
public override bool Done()
{
bool flag = this.GotResult || this.sock == null;
bool flag2;
if (flag)
{
flag2 = true;
}
else
{
bool flag3 = this.sock.Available <= 0;
if (flag3)
{
flag2 = false;
}
else
{
int num = this.sock.Receive(this.PingBytes, SocketFlags.None);
bool flag4 = this.PingBytes[this.PingBytes.Length - 1] == this.PingId && num == this.PingLength;
bool flag5 = !flag4;
if (flag5)
{
this.DebugString += " ReplyMatch is false! ";
}
this.Successful = num == this.PingBytes.Length && this.PingBytes[this.PingBytes.Length - 1] == this.PingId;
this.GotResult = true;
flag2 = true;
}
}
return flag2;
}
// Token: 0x06000216 RID: 534 RVA: 0x00011ABC File Offset: 0x0000FCBC
public override void Dispose()
{
try
{
this.sock.Close();
}
catch
{
}
this.sock = null;
}
// Token: 0x04000133 RID: 307
private Socket sock;
}
}