コード例 #1
0
        // No array gathering support so one by one
        private void SendOne(org.objectfabric.Queue buffs)
        {
            org.objectfabric.CLRBuff buff = (org.objectfabric.CLRBuff)buffs.poll();

            if (buff == null)
            {
                WriteComplete();
            }
            else
            {
                try
                {
                    ArraySegment <byte> buffer = new ArraySegment <byte>(buff.array(), buff.position(), buff.limit() - buff.position());
                    Task task = _socket.SendAsync(buffer, WebSocketMessageType.Binary, false, CancellationToken.None);

                    task.ContinueWith(_ =>
                    {
                        Recycle(buff);
                        SendOne(buffs);
                    });
                }
                catch (Exception ex)
                {
                    Recycle(buff);
                    OnError(ex);
                }
            }
        }
コード例 #2
0
        protected override void Write()
        {
            org.objectfabric.Queue buffs = Fill(0xffff);

            if (buffs != null)
            {
                SendOne(buffs);
            }
        }