Ejemplo n.º 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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 4
0
 public override void Disconnect()
 {
     state = ClientState.Disconnecting;
     // disconnect should cause closeCallback and OnDisconnect to be called
     SimpleWebJSLib.Disconnect(index);
 }
Ejemplo n.º 5
0
 public override void Connect(Uri serverAddress)
 {
     index = SimpleWebJSLib.Connect(serverAddress.ToString(), OpenCallback, CloseCallBack, MessageCallback, ErrorCallback);
     instances.Add(index, this);
     state = ClientState.Connecting;
 }
Ejemplo n.º 6
0
 public bool CheckJsConnected() => SimpleWebJSLib.IsConnected(index);