온라인 구현

This commit is contained in:
김도환
2026-05-01 05:47:12 +09:00
parent 5695b4036f
commit a36270f77a
996 changed files with 267058 additions and 75 deletions

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 887ac71c799552346b6cf7654fb699cb
folderAsset: yes
DefaultImporter:
userData:

Binary file not shown.

View File

@@ -0,0 +1,48 @@
fileFormatVersion: 2
guid: 3b5a0a7dce46a13459199d174ad3db3f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
'': Any
second:
enabled: 1
settings: {}
- first:
'': WP8
second:
enabled: 1
settings:
CPU: AnyCPU
DontProcess: False
PlaceholderPath: Assets/Photon/PhotonLibs/Photon3Unity3D.dll
SDK: AnySDK
ScriptingBackend: DotNet
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 1
settings:
CPU: AnyCPU
DontProcess: false
PlaceholderPath: Assets/Photon/PhotonLibs/Photon3Unity3D.dll
SDK: AnySDK
ScriptingBackend: DotNet
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.dll
uploadId: 817708

Binary file not shown.

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 3439a9e4030efca45b6cc06240106c02
timeCreated: 1460035811
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.pri
uploadId: 817708

Binary file not shown.

View File

@@ -0,0 +1,45 @@
fileFormatVersion: 2
guid: aadb37a20a33632429047acaef43658a
labels:
- ExitGames
- PUN
- Photon
- Networking
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
'': Any
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/Photon3Unity3D.dll
uploadId: 817708

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
fileFormatVersion: 2
guid: 8d4f08d435c4b6343969d8af249460ff
labels:
- ExitGames
- PUN
- Photon
- Networking
TextScriptImporter:
userData:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/Photon3Unity3D.xml
uploadId: 817708

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 2f243ce0406bd1c40a9ff5fc2d78d905
folderAsset: yes
DefaultImporter:
userData:

View File

@@ -0,0 +1,15 @@
{
"name": "PhotonWebSocket",
"references": [],
"includePlatforms": [
"WebGL"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: a10ff188cbfd201409863c062b118e1d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/WebSocket/PhotonWebSocket.asmdef
uploadId: 817708

View File

@@ -0,0 +1,352 @@
#if UNITY_WEBGL || WEBSOCKET || WEBSOCKET_PROXYCONFIG
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SocketWebTcp.cs" company="Exit Games GmbH">
// Copyright (c) Exit Games GmbH. All rights reserved.
// </copyright>
// <summary>
// Internal class to encapsulate the network i/o functionality for the realtime library.
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
namespace ExitGames.Client.Photon
{
using System;
#if UNITY_2019_3_OR_NEWER
using UnityEngine.Scripting;
#endif
/// <summary>
/// Internal class to encapsulate the network i/o functionality for the realtime library.
/// </summary>
[Preserve]
public class SocketWebTcp : IPhotonSocket, IDisposable
{
private WebSocket sock;
private readonly object syncer = new object();
[Preserve]
public SocketWebTcp(PeerBase npeer) : base(npeer)
{
this.ServerAddress = npeer.ServerAddress;
this.ProxyServerAddress = npeer.ProxyServerAddress;
if (this.ReportDebugOfLevel(DebugLevel.INFO))
{
this.Listener.DebugReturn(DebugLevel.INFO, "SocketWebTcp() "+ WebSocket.Implementation+". Server: " + this.ServerAddress + (String.IsNullOrEmpty(this.ProxyServerAddress) ? "" : ", Proxy: " + this.ProxyServerAddress));
}
this.PollReceive = false;
}
public void Dispose()
{
this.State = PhotonSocketState.Disconnecting;
if (this.sock != null)
{
try
{
if (this.sock.Connected)
{
this.sock.Close();
}
}
catch (Exception ex)
{
this.EnqueueDebugReturn(DebugLevel.INFO, "Exception in SocketWebTcp.Dispose(): " + ex);
}
}
this.sock = null;
this.State = PhotonSocketState.Disconnected;
}
public override bool Connect()
{
this.State = PhotonSocketState.Connecting;
if (!this.ConnectAddress.Contains("IPv6"))
{
this.ConnectAddress += "&IPv6"; // this makes the Photon Server return a host name for the next server (NS points to MS and MS points to GS)
}
// earlier, we read the proxy address/scheme and failed to connect entirely, if that wasn't successful...
// it was either successful (using the resulting proxy address) or no connect at all...
// we want:
// WITH support: fail if the scheme is wrong or use it if possible
// WITHOUT support: use proxy address, if it's a direct value (not a scheme we provide) or fail if it's a scheme
string proxyServerAddress;
if (!this.ReadProxyConfigScheme(this.ProxyServerAddress, this.ServerAddress, out proxyServerAddress))
{
this.Listener.DebugReturn(DebugLevel.INFO, "ReadProxyConfigScheme() failed. Using no proxy.");
}
try
{
this.sock = new WebSocket(new Uri(this.ConnectAddress), proxyServerAddress, this.OpenCallback, this.ReceiveCallback, this.ErrorCallback, this.CloseCallback, this.SerializationProtocol);
this.sock.DebugReturn = (DebugLevel l, string s) =>
{
if (this.State != PhotonSocketState.Disconnected)
{
this.Listener.DebugReturn(l, this.State + " " + s);
}
};
this.sock.Connect();
return true;
}
catch (Exception e)
{
this.Listener.DebugReturn(DebugLevel.ERROR, "SocketWebTcp.Connect() caught exception: " + e);
return false;
}
}
private void CloseCallback(int code, string reason)
{
if (this.State == PhotonSocketState.Connecting)
{
this.HandleException(StatusCode.ExceptionOnConnect); // sets state to Disconnecting
return;
}
// passing-on close only if this socket is still used / expected to be connected
if (this.State != PhotonSocketState.Disconnecting && this.State != PhotonSocketState.Disconnected)
{
this.Listener.DebugReturn(DebugLevel.ERROR, "SocketWebTcp.CloseCallback(). Going to disconnect. Server: " + this.ServerAddress + " Error: " + code + " Reason: " + reason);
this.HandleException(StatusCode.DisconnectByServerReasonUnknown); // sets state to Disconnecting
}
}
// code can be from JsLib or WebSocket-Sharp, so it is not guaranteed to be the same in both cases
private void ErrorCallback(int code, string message)
{
// passing-on errors only if this socket is still used / expected to be connected
if (this.State != PhotonSocketState.Disconnecting && this.State != PhotonSocketState.Disconnected)
{
this.Listener.DebugReturn(DebugLevel.ERROR, "SocketWebTcp.ErrorCallback(). Going to disconnect. Server: " + this.ServerAddress + " Error: " + code + " Message: " + message);
this.HandleException(this.State != PhotonSocketState.Connected ? StatusCode.ExceptionOnConnect : StatusCode.ExceptionOnReceive); // sets state to Disconnecting
}
}
private void OpenCallback()
{
if (State == PhotonSocketState.Connecting)
{
this.State = PhotonSocketState.Connected;
this.peerBase.OnConnect();
}
}
/// <summary>
/// Attempts to read a proxy configuration defined by a address prefix. Only available to Industries Circle members on demand.
/// </summary>
/// <remarks>
/// Extended proxy support is available to Industries Circle members. Where available, proxy addresses may be defined as 'auto:', 'pac:' or 'system:'.
/// In all other cases, the proxy address is used as is and fails to read configs (if one of the listed schemes is used).
///
/// Requires file ProxyAutoConfig.cs and compile define: WEBSOCKET_PROXYCONFIG_SUPPORT.
/// </remarks>
/// <param name="proxyAddress">Proxy address from the server configuration.</param>
/// <param name="url">Url to connect to (one of the Photon servers).</param>
/// <param name="proxyUrl">Resulting proxy URL to use.</param>
/// <returns>False if there is some error and the resulting proxy address should not be used.</returns>
private bool ReadProxyConfigScheme(string proxyAddress, string url, out string proxyUrl)
{
proxyUrl = null;
#if !WEBSOCKET_PROXYCONFIG
if (!string.IsNullOrEmpty(proxyAddress))
{
if (proxyAddress.StartsWith("auto:") || proxyAddress.StartsWith("pac:") || proxyAddress.StartsWith("system:"))
{
this.Listener.DebugReturn(DebugLevel.WARNING, "Proxy configuration via auto, pac or system is only supported with the WEBSOCKET_PROXYCONFIG define. Using no proxy instead.");
return true;
}
proxyUrl = proxyAddress;
}
return true;
#else
if (!string.IsNullOrEmpty(proxyAddress))
{
var httpUrl = url.ToString().Replace("ws://", "http://").Replace("wss://", "https://"); // http(s) schema required in GetProxyForUrlUsingPac call
bool auto = proxyAddress.StartsWith("auto:", StringComparison.InvariantCultureIgnoreCase);
bool pac = proxyAddress.StartsWith("pac:", StringComparison.InvariantCultureIgnoreCase);
if (auto || pac)
{
string pacUrl = "";
if (pac)
{
pacUrl = proxyAddress.Substring(4);
if (pacUrl.IndexOf("://") == -1)
{
pacUrl = "http://" + pacUrl; //default to http
}
}
string processTypeStr = auto ? "auto detect" : "pac url " + pacUrl;
this.Listener.DebugReturn(DebugLevel.INFO, "WebSocket Proxy: " + url + " " + processTypeStr);
string errDescr = "";
var err = ProxyAutoConfig.GetProxyForUrlUsingPac(httpUrl, pacUrl, out proxyUrl, out errDescr);
if (err != 0)
{
this.Listener.DebugReturn(DebugLevel.ERROR, "WebSocket Proxy: " + url + " " + processTypeStr + " ProxyAutoConfig.GetProxyForUrlUsingPac() error: " + err + " (" + errDescr + ")");
return false;
}
}
else if (proxyAddress.StartsWith("system:", StringComparison.InvariantCultureIgnoreCase))
{
this.Listener.DebugReturn(DebugLevel.INFO, "WebSocket Proxy: " + url + " system settings");
string proxyAutoConfigPacUrl;
var err = ProxySystemSettings.GetProxy(out proxyUrl, out proxyAutoConfigPacUrl);
if (err != 0)
{
this.Listener.DebugReturn(DebugLevel.ERROR, "WebSocket Proxy: " + url + " system settings ProxySystemSettings.GetProxy() error: " + err);
return false;
}
if (proxyAutoConfigPacUrl != null)
{
if (proxyAutoConfigPacUrl.IndexOf("://") == -1)
{
proxyAutoConfigPacUrl = "http://" + proxyAutoConfigPacUrl; //default to http
}
this.Listener.DebugReturn(DebugLevel.INFO, "WebSocket Proxy: " + url + " system settings AutoConfigURL: " + proxyAutoConfigPacUrl);
string errDescr = "";
err = ProxyAutoConfig.GetProxyForUrlUsingPac(httpUrl, proxyAutoConfigPacUrl, out proxyUrl, out errDescr);
if (err != 0)
{
this.Listener.DebugReturn(DebugLevel.ERROR, "WebSocket Proxy: " + url + " system settings AutoConfigURLerror: " + err + " (" + errDescr + ")");
return false;
}
}
}
else
{
proxyUrl = proxyAddress;
}
this.Listener.DebugReturn(DebugLevel.INFO, "WebSocket Proxy: " + url + " -> " + (string.IsNullOrEmpty(proxyUrl) ? "DIRECT" : "PROXY " + proxyUrl));
}
return true;
#endif
}
public override bool Disconnect()
{
if (this.ReportDebugOfLevel(DebugLevel.INFO))
{
this.Listener.DebugReturn(DebugLevel.INFO, "SocketWebTcp.Disconnect()");
}
this.State = PhotonSocketState.Disconnecting;
lock (this.syncer)
{
if (this.sock != null)
{
try
{
this.sock.Close();
}
catch (Exception ex)
{
this.Listener.DebugReturn(DebugLevel.ERROR, "Exception in SocketWebTcp.Disconnect(): " + ex);
}
this.sock = null;
}
}
this.State = PhotonSocketState.Disconnected;
return true;
}
/// <summary>Used by TPeer</summary>
public override PhotonSocketError Send(byte[] data, int length)
{
if (this.State != PhotonSocketState.Connected)
{
return PhotonSocketError.Skipped;
}
try
{
if (data.Length > length)
{
byte[] trimmedData = new byte[length];
Buffer.BlockCopy(data, 0, trimmedData, 0, length);
data = trimmedData;
}
if (this.sock != null)
{
this.sock.Send(data);
}
}
catch (Exception e)
{
this.Listener.DebugReturn(DebugLevel.ERROR, "Cannot send to: " + this.ServerAddress + ". " + e.Message);
this.HandleException(StatusCode.Exception);
return PhotonSocketError.Exception;
}
return PhotonSocketError.Success;
}
public override PhotonSocketError Receive(out byte[] data)
{
data = null;
return PhotonSocketError.NoData;
}
public void ReceiveCallback(byte[] buf, int len)
{
// once the websocket is disconnecting / disconnected, it should not receive anything anymore
if (State == PhotonSocketState.Disconnecting || State == PhotonSocketState.Disconnected)
{
return;
}
try
{
this.HandleReceivedDatagram(buf, len, false);
}
catch (Exception e)
{
if (this.State != PhotonSocketState.Disconnecting && this.State != PhotonSocketState.Disconnected)
{
if (this.ReportDebugOfLevel(DebugLevel.ERROR))
{
this.EnqueueDebugReturn(DebugLevel.ERROR, "SocketWebTcp.ReceiveCallback() caught exception. Going to disconnect. State: " + this.State + ". Server: '" + this.ServerAddress + "' Exception: " + e);
}
this.HandleException(StatusCode.ExceptionOnReceive);
}
}
}
}
}
#endif

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: ac953d6a57a9ea94e96ec689598995d5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/WebSocket/SocketWebTcp.cs
uploadId: 817708

View File

@@ -0,0 +1,347 @@
#if UNITY_WEBGL || WEBSOCKET || WEBSOCKET_PROXYCONFIG
#if UNITY_WEBGL && !UNITY_EDITOR
#define PHOTON_WEBSOCKET_JS
#else
#define PHOTON_WEBSOCKET_CS
#endif
// --------------------------------------------------------------------------------------------------------------------
// <summary>
// Provided originally by Unity to cover WebSocket support in WebGL and the Editor. Modified by Exit Games GmbH.
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
namespace ExitGames.Client.Photon
{
using System;
#if PHOTON_WEBSOCKET_JS
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using AOT;
#else
using WebSocketSharp;
using System.Security.Authentication;
#endif
// changed mProxyAddress to ProxyAddress
// changed mUrl to Url
public partial class WebSocket
{
/// <summary>Server address</summary>
public Uri Url { get; private set; }
/// <summary>Only supported by WebSocket-sharp dll.</summary>
public string ProxyAddress { get; private set; }
/// <summary>Photon uses this to agree on a serialization protocol. Either: GpBinaryV16 or GpBinaryV18. Based on enum SerializationProtocol.</summary>
private readonly string protocols = "GpBinaryV16";
/// <summary>True after the websocket callback OnConnect until close or (permanent) error.</summary>
public bool Connected { get; private set; }
/// <summary>Null until some error happened in underlying websocket.</summary>
public string Error { get; private set; }
// callbacks to higher level
private Action<byte[], int> recvCallback;
private Action openCallback;
private Action<int, string> errorCallback;
private Action<int, string> closeCallback;
// logging callback
public Action<DebugLevel, string> DebugReturn { get; set; }
public WebSocket(Uri url, string proxyAddress, Action openCallback, Action<byte[], int> recvCallback, Action<int, string> errorCallback, Action<int, string> closeCallback, string protocols = null)
{
this.Url = url;
this.ProxyAddress = proxyAddress;
this.recvCallback = recvCallback;
this.openCallback = openCallback;
this.errorCallback = errorCallback;
this.closeCallback = closeCallback;
if (!string.IsNullOrEmpty(protocols))
{
this.protocols = protocols;
}
string scheme = this.Url.Scheme;
if (!scheme.Equals("ws") && !scheme.Equals("wss"))
{
throw new ArgumentException("Unsupported protocol: " + scheme);
}
}
}
// .net specific implementation using websocket-sharp.dll
public partial class WebSocket
{
#if PHOTON_WEBSOCKET_CS
public const string Implementation = "WebSocketSharp";
WebSocketSharp.WebSocket m_Socket;
public void Connect()
{
this.m_Socket = new WebSocketSharp.WebSocket(this.Url.ToString(), new string[] {this.protocols});
this.m_Socket.Log.Output = (ld, f) =>
{
var s = string.Format("WebSocketSharp: {0}", ld.Message);
switch (ld.Level)
{
case LogLevel.Trace:
case LogLevel.Debug:
this.DebugReturn(DebugLevel.ALL, s);
break;
case LogLevel.Info:
this.DebugReturn(DebugLevel.INFO, s);
break;
case LogLevel.Warn:
this.DebugReturn(DebugLevel.WARNING, s);
break;
case LogLevel.Error:
case LogLevel.Fatal:
this.DebugReturn(DebugLevel.ERROR, s);
break;
}
};
this.m_Socket.OnOpen += (sender, e) =>
{
this.Connected = true;
this.openCallback();
};
this.m_Socket.OnMessage += (sender, e) =>
{
this.recvCallback(e.RawData, e.RawData.Length);
};
this.m_Socket.OnError += (sender, e) =>
{
this.Connected = false;
this.Error = e.Message + (e.Exception == null ? "" : " / " + e.Exception);
this.errorCallback(0, e.Message);
};
this.m_Socket.OnClose += (sender, e) =>
{
this.Connected = false;
this.closeCallback(e.Code, e.Reason);
};
if (!String.IsNullOrEmpty(this.ProxyAddress))
{
string user = null;
string pass = null;
var authDelim = this.ProxyAddress.IndexOf("@");
if (authDelim != -1)
{
user = this.ProxyAddress.Substring(0, authDelim);
this.ProxyAddress = this.ProxyAddress.Substring(authDelim + 1);
var passDelim = user.IndexOf(":");
if (passDelim != -1)
{
pass = user.Substring(passDelim + 1);
user = user.Substring(0, passDelim);
}
}
// throws an exception, if scheme not specified
this.m_Socket.SetProxy("http://" + this.ProxyAddress, user, pass);
}
if (this.m_Socket.IsSecure)
{
this.m_Socket.SslConfiguration.EnabledSslProtocols = this.m_Socket.SslConfiguration.EnabledSslProtocols | (SslProtocols)(3072 | 768);
}
this.m_Socket.ConnectAsync();
}
public void Close()
{
// at this low level we are fine with closing the socket async / non-blocking
this.m_Socket.CloseAsync();
}
public void Send(byte[] buffer)
{
this.m_Socket.Send(buffer);
}
#endif
}
// js/native specific implementation
public partial class WebSocket
{
#if PHOTON_WEBSOCKET_JS
public const string Implementation = "JsLib";
static Dictionary<int, WebSocket> instances = new Dictionary<int, WebSocket>();
[DllImport("__Internal")]
private static extern int SocketCreate(string url, string protocols, Action<int> openCallbackStatic, Action<int, IntPtr, int> recvCallbackStatic, Action<int, int> errorCallbackStatic, Action<int, int> closeCallbackStatic);
[DllImport("__Internal")]
private static extern int SocketState (int socketInstance);
[DllImport("__Internal")]
private static extern void SocketSend (int socketInstance, byte[] ptr, int length);
[DllImport("__Internal")]
private static extern void SocketClose (int socketInstance);
[DllImport("__Internal")]
private static extern int SocketError (int socketInstance, byte[] ptr, int length);
private int m_NativeRef = 0;
// TODO: discuss if we need this anymore?!
public bool ConnectedOLD
{
get { return SocketState(m_NativeRef) != 0; }
}
private const int SocketErrorBufferSize = 1024;
private readonly byte[] socketErrorBuffer = new byte[SocketErrorBufferSize];
// TODO: discuss if we need this anymore?!
public string ErrorOLD
{
get {
int result = SocketError (m_NativeRef, this.socketErrorBuffer, SocketErrorBufferSize);
if (result == 0)
return null;
return Encoding.UTF8.GetString (this.socketErrorBuffer);
}
}
public void Connect()
{
m_NativeRef = SocketCreate (this.Url.ToString(), this.protocols, OpenCallbackStatic, RecvCallbackStatic, ErrorCallbackStatic, CloseCallbackStatic);
instances[m_NativeRef] = this;
}
public void Close()
{
SocketClose(m_NativeRef);
}
public void Send(byte[] buffer)
{
SocketSend (m_NativeRef, buffer, buffer.Length);
}
[MonoPInvokeCallback(typeof(Action<int, IntPtr, int>))]
public static void RecvCallbackStatic(int instance, IntPtr p, int len)
{
instances[instance].RecvCallbackInstance(p, len);
}
private byte[] receiveBuffer;
public void RecvCallbackInstance(IntPtr p, int len)
{
if (this.receiveBuffer == null || this.receiveBuffer.Length < len)
{
this.receiveBuffer = new byte[len];
}
Marshal.Copy(p, this.receiveBuffer, 0, len);
this.recvCallback(this.receiveBuffer, len);
}
[MonoPInvokeCallback(typeof(Action<int>))]
public static void OpenCallbackStatic(int instance)
{
instances[instance].OpenCallbackInstance();
}
public void OpenCallbackInstance()
{
this.Connected = true;
this.openCallback();
}
[MonoPInvokeCallback(typeof(Action<int, int>))]
public static void ErrorCallbackStatic(int instance, int code)
{
string msg;
switch (code)
{
case 1001:
msg = "Endpoint going away.";
break;
case 1002:
msg = "Protocol error.";
break;
case 1003:
msg = "Unsupported message.";
break;
case 1005:
msg = "No status.";
break;
case 1006:
msg = "Abnormal disconnection.";
break;
case 1009:
msg = "Data frame too large.";
break;
default:
msg = "Error " + code;
break;
}
instances[instance].ErrorCallbackInstance(code, msg);
}
public void ErrorCallbackInstance(int code, string msg)
{
this.Connected = false;
this.errorCallback(code, msg);
}
[MonoPInvokeCallback(typeof(Action<int, int>))]
public static void CloseCallbackStatic(int instance, int code)
{
string msg = "n/a from jslib";
instances[instance].CloseCallbackInstance(code, msg);
}
public void CloseCallbackInstance(int code, string msg)
{
this.Connected = false;
this.closeCallback(code, msg);
}
#endif
}
}
#endif

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: b1bad04f7805f764dba77f0d4518e0f0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/WebSocket/WebSocket.cs
uploadId: 817708

View File

@@ -0,0 +1,88 @@
var LibraryWebSockets = {
$webSocketInstances: [],
SocketCreate: function(url, protocols, openCallback, recvCallback, errorCallback, closeCallback)
{
var str = UTF8ToString(url);
var prot = UTF8ToString(protocols);
var socket = {
socket: new WebSocket(str, [prot]),
error: null,
sendBufForShared: null,
send: typeof(SharedArrayBuffer) == "function" ? // SharedArrayBuffer is available and will not crash in 'isinstance' check
function (socketInstance, ptr, length) {
if (HEAPU8.buffer instanceof SharedArrayBuffer) {
if (!this.sendBufForShared || this.sendBufForShared.byteLength < length) {
this.sendBufForShared = new ArrayBuffer(length);
}
var u8arr = new Uint8Array(this.sendBufForShared, 0, length);
u8arr.set(new Uint8Array(HEAPU8.buffer, ptr, length));
this.socket.send(u8arr);
} else {
this.socket.send(new Uint8Array(HEAPU8.buffer, ptr, length));
}
}
:
function (socketInstance, ptr, length) { // SharedArrayBuffer is not defined, ptr type is always ArrayBuffer
this.socket.send(new Uint8Array(HEAPU8.buffer, ptr, length));
}
}
var instance = webSocketInstances.push(socket) - 1;
socket.socket.binaryType = 'arraybuffer';
socket.socket.onopen = function () {
{{{ makeDynCall('vi', 'openCallback') }}}(instance);
}
socket.socket.onmessage = function (e) {
if (e.data instanceof ArrayBuffer)
{
const b = e.data;
const ptr = _malloc(b.byteLength);
const dataHeap = new Int8Array(HEAPU8.buffer, ptr, b.byteLength);
dataHeap.set(new Int8Array(b));
{{{ makeDynCall('viii', 'recvCallback') }}}(instance, ptr, b.byteLength);
_free(ptr);
}
};
socket.socket.onerror = function (e) {
{{{ makeDynCall('vii', 'errorCallback') }}}(instance, e.code);
}
socket.socket.onclose = function (e) {
if (e.code != 1000)
{
{{{ makeDynCall('vii', 'closeCallback') }}}(instance, e.code);
}
}
return instance;
},
SocketState: function (socketInstance)
{
var socket = webSocketInstances[socketInstance];
return socket.socket.readyState;
},
SocketError: function (socketInstance, ptr, bufsize)
{
var socket = webSocketInstances[socketInstance];
if (socket.error == null)
return 0;
stringToUTF8(socket.error, ptr, bufsize);
return 1;
},
SocketSend: function (socketInstance, ptr, bufsize)
{
var socket = webSocketInstances[socketInstance];
socket.send(socketInstance, ptr, bufsize);
},
SocketClose: function (socketInstance)
{
var socket = webSocketInstances[socketInstance];
socket.socket.close();
}
};
autoAddDeps(LibraryWebSockets, '$webSocketInstances');
mergeInto(LibraryManager.library, LibraryWebSockets);

View File

@@ -0,0 +1,39 @@
fileFormatVersion: 2
guid: 04bb5f307f2e48b4fbaa6da865fd4091
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/WebSocket/WebSocket.jslib
uploadId: 817708

View File

@@ -0,0 +1,5 @@
UPDATED: WebSocket/websocket-sharp.dll from our own Git Fork. Commit: 77f74bd
forked from https://github.com/sta/websocket-sharp.git
websocket-sharp is provided under The MIT License as mentioned here: https://github.com/sta/websocket-sharp#license

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3e262c2b04eaa8440987b50a91e86674
DefaultImporter:
userData:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/WebSocket/websocket-sharp.README
uploadId: 817708

Binary file not shown.

View File

@@ -0,0 +1,147 @@
fileFormatVersion: 2
guid: 748eb70bc0d7515498ef73fed155520a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 0
Exclude Linux: 0
Exclude Linux64: 0
Exclude LinuxUniversal: 0
Exclude OSXUniversal: 0
Exclude WebGL: 1
Exclude Win: 0
Exclude Win64: 0
Exclude WindowsStoreApps: 1
- first:
: OSXIntel
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
: OSXIntel64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
: WP8
second:
enabled: 0
settings:
CPU: AnyCPU
DontProcess: False
PlaceholderPath:
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
DontProcess: False
PlaceholderPath:
SDK: AnySDK
ScriptingBackend: AnyScriptingBackend
- first:
XboxOne: XboxOne
second:
enabled: 0
settings: {}
- first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/WebSocket/websocket-sharp.dll
uploadId: 817708

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: d8040d310df77714a90a561261bfb2cb
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/changes-library.txt
uploadId: 817708

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: beb9d2a25c882b54ab2fd9adaec2b53c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,47 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"Photon3Unity3D/4.1.8.17": {
"dependencies": {
"NETStandard.Library": "2.0.3"
},
"runtime": {
"Photon3Unity3D.dll": {}
}
},
"Microsoft.NETCore.Platforms/1.1.0": {},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
}
}
},
"libraries": {
"Photon3Unity3D/4.1.8.17": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
}
}
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: a966b98b651e18748abf2829786b5899
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/netstandard2.0/Photon3Unity3D.deps.json
uploadId: 817708

View File

@@ -0,0 +1,172 @@
fileFormatVersion: 2
guid: 6a558ae793155af4b9b9ab945fc64a0f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 0
Exclude GameCoreScarlett: 0
Exclude GameCoreXboxOne: 0
Exclude Linux: 0
Exclude Linux64: 0
Exclude LinuxUniversal: 0
Exclude Lumin: 0
Exclude OSXUniversal: 0
Exclude PS4: 0
Exclude PS5: 0
Exclude Switch: 0
Exclude WebGL: 0
Exclude Win: 0
Exclude Win64: 0
Exclude WindowsStoreApps: 0
Exclude XboxOne: 0
Exclude iOS: 0
Exclude tvOS: 0
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: LinuxUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 1
settings:
CPU: AnyCPU
DontProcess: false
PlaceholderPath:
SDK: AnySDK
ScriptingBackend: Il2Cpp
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
CompileFlags:
FrameworkDependencies:
- first:
PS4: PS4
second:
enabled: 1
settings: {}
- first:
PS5: PS5
second:
enabled: 1
settings: {}
- first:
Nintendo Switch: Switch
second:
enabled: 1
settings: {}
- first:
XboxOne: XboxOne
second:
enabled: 1
settings: {}
- first:
GameCoreScarlett: GameCoreScarlett
second:
enabled: 1
settings: {}
- first:
GameCoreXboxOne: GameCoreXboxOne
second:
enabled: 1
settings: {}
- first:
Lumin: Lumin
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/netstandard2.0/Photon3Unity3D.dll
uploadId: 817708

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 7015e500cd5b71244af56448dfb59804
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonLibs/netstandard2.0/Photon3Unity3D.xml
uploadId: 817708