コード例 #1
0
        void onOpen()
        {
            receiveQueue.Enqueue(new Message(EventType.Connected));
            state = ClientState.Connected;

            if (ConnectingSendQueue != null)
            {
                while (ConnectingSendQueue.Count > 0)
                {
                    byte[] next = ConnectingSendQueue.Dequeue();
                    SimpleWebJSLib.Send(index, next, 0, next.Length);
                }
                ConnectingSendQueue = null;
            }
        }
コード例 #2
0
        public override void Send(ArraySegment <byte> segment)
        {
            if (segment.Count > maxMessageSize)
            {
                Log.Error($"Cant send message with length {segment.Count} because it is over the max size of {maxMessageSize}");
                return;
            }

            if (state == ClientState.Connected)
            {
                SimpleWebJSLib.Send(index, segment.Array, segment.Offset, segment.Count);
            }
            else
            {
                if (ConnectingSendQueue == null)
                {
                    ConnectingSendQueue = new Queue <byte[]>();
                }
                ConnectingSendQueue.Enqueue(segment.ToArray());
            }
        }