Example #1
0
        void OnWebSocketOpen(object sender, EventArgs e)
        {
            //print("opened");
            opened = true;

            try
            {
                if (handle != null)
                {
                    handle.OnConnected();
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }
Example #2
0
        void Update()
        {
            if (status == Status.Disconnected && autoConnect)
            {
                Connect();
            }


            string[] messages = null;
            lock (messageQueue)
            {
                messages = messageQueue.ToArray();
                messageQueue.Clear();
            }

            if (handle != null)
            {
                foreach (var message in messages)
                {
                    handle.OnRawString(message);
                }
            }

            if (status != lastStatus)
            {
                lastStatus = status;
                if (handle != null)
                {
                    switch (status)
                    {
                    case Status.Connected:
                        handle.OnConnected();
                        break;

                    case Status.Connecting:
                        handle.OnConnecting();
                        break;

                    case Status.Disconnected:
                        handle.OnDisconencted();
                        break;
                    }
                }
            }
        }