Пример #1
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;
            }

            SimpleWebJSLib.Send(index, segment.Array, 0, segment.Count);
        }
Пример #2
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;
            }
        }
Пример #3
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());
            }
        }