Exemplo n.º 1
0
        private void SendResponse(Stream writer, OutMessage resp)
        {
            FunctionSerializer funcSer    = new FunctionSerializer();
            BufferSerializer   buffSer    = new BufferSerializer();
            string             serialized = JsonConvert.SerializeObject(new { resp.id, resp.callback, resp.data, resp.error }, funcSer, buffSer);

            mCallbacks[resp.id] = funcSer.callbacks;
            var input = System.Text.Encoding.UTF8.GetBytes(serialized + "\uFFFF");

            writer.Write(input, 0, input.Length);
        }
Exemplo n.º 2
0
        private void WriterLoop(Stream writer, BlockingCollection <OutMessage> outgoing)
        {
            bool running = true;

            try
            {
                while (running)
                {
                    OutMessage msg = outgoing.Take();
                    SendResponse(writer, msg);
                }
            } catch (InvalidOperationException)
            {
                // queue was closed by the producer
                return;
            }
        }