Esempio n. 1
0
        private void ProcessChanges(FTEMessage message)
        {
            var changesMsg = message.GetMessage <Changes>();

            List <TaskCompletionSource <bool> > tcsList = new List <TaskCompletionSource <bool> >(1);

            foreach (var row in changesMsg.row)
            {
                var rowChange = MessageParser.Deserialize <RowChange>(row);
                ProcessRow(rowChange);

                lock (sync)
                {
                    TaskCompletionSource <bool> tcs;
                    if (subscriptions.TryGetValue(rowChange.tabId, out tcs))
                    {
                        subscriptions.Remove(rowChange.tabId);
                        tcsList.Add(tcs);
                    }
                }
            }

            foreach (var tcs in tcsList)
            {
                tcs.SetResult(true);
            }
        }
Esempio n. 2
0
        protected async Task SendRequestAsync(FTEMessage message)
        {
            var reply = await this.SendMessageAsync(message);

            if (!reply.IsReplyOk)
            {
                throw new FTEException(reply.Type);
            }
        }
Esempio n. 3
0
        protected async Task <T> SendRequestAsync <T>(FTEMessage message)
            where T : class, IExtensible
        {
            var reply = await this.SendMessageAsync(message);

            if (!reply.IsReplyOk)
            {
                throw new FTEException(reply.Type);
            }

            return(reply.GetMessage <T>());
        }
Esempio n. 4
0
        protected override void OnMessage(FTEMessage messages)
        {
            switch (messages.Type)
            {
            case MsgType.OK_CHANGES:
                ProcessChanges(messages);
                break;

            default:
                return;
            }
        }
Esempio n. 5
0
        protected Task <FTEMessage> SendMessageAsync(FTEMessage message)
        {
            var reqid = (ulong)Interlocked.Increment(ref reqidCounter);
            var tcs   = new TaskCompletionSource <FTEMessage>();

            lock (sync)
            {
                requests[reqid] = tcs;
            }
            this.SendMessage(message, reqid);

            return(tcs.Task);
        }
Esempio n. 6
0
        private void SendMessage(FTEMessage message, ulong reqid = default(ulong))
        {
            Envelope env = new Envelope
            {
                ver   = 1,
                reqid = reqid,
                uid   = username,
                //cryptoresult = SignCheckResult.SCHECK_OK,
            };

            env.type.Add(message.Type);
            if (message.HasData)
            {
                env.data.Add(message.Body);
            }

            base.SendMessage(env.Serialize());
        }
Esempio n. 7
0
 protected virtual void OnMessage(FTEMessage messages)
 {
 }