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); } }
protected async Task SendRequestAsync(FTEMessage message) { var reply = await this.SendMessageAsync(message); if (!reply.IsReplyOk) { throw new FTEException(reply.Type); } }
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>()); }
protected override void OnMessage(FTEMessage messages) { switch (messages.Type) { case MsgType.OK_CHANGES: ProcessChanges(messages); break; default: return; } }
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); }
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()); }
protected virtual void OnMessage(FTEMessage messages) { }