Beispiel #1
0
        private void CreateSocket()
        {
            if (Socket != null)
            {
                throw new InvalidOperationException("Socket already created");
            }

            GameObject go = new GameObject(
                "UnisaveBroadcastingSseSocket",
                typeof(SseSocket)
                );

            UnityEngine.Object.DontDestroyOnLoad(go);

            if (!app.InEditMode)
            {
                go.transform.parent = app.GameObject.transform;
            }

            Socket = go.GetComponent <SseSocket>();
            Socket.Initialize(app);
            Socket.OnEventReceived      += OnEventReceived;
            Socket.OnConnectionLost     += ConnectionLostDelegator;
            Socket.OnConnectionRegained += ConnectionRegainedDelegator;
        }
Beispiel #2
0
        private void DisposeSocket()
        {
            if (Socket == null)
            {
                return;
            }

            Socket.OnEventReceived      -= OnEventReceived;
            Socket.OnConnectionLost     -= ConnectionLostDelegator;
            Socket.OnConnectionRegained -= ConnectionRegainedDelegator;

            UnityEngine.Object.Destroy(Socket.gameObject);
            Socket = null;
        }