private JObject Serialize(OutgoingRtmEvent slackEvent, out uint id) { var json = JObject.FromObject(slackEvent, JsonSerializer.Create(_jsonSettings.SerializerSettings)); id = _nextEventId++; json["id"] = id; return(json); }
/// <summary> /// Low-level method for sending an arbitrary message over the websocket where a reply is expected. /// </summary> public async Task <Reply> SendWithReply(OutgoingRtmEvent slackEvent) { var json = Serialize(slackEvent, out var id); var reply = _rawEvents.OfType <Reply>() .Where(r => r.ReplyTo == id) .FirstOrDefaultAsync() .ToTask(); Send(json); return(await reply.ConfigureAwait(false)); }
/// <summary> /// Low-level method for sending an arbitrary message over the websocket where no reply is expected. /// </summary> public void Send(OutgoingRtmEvent slackEvent) => Send(Serialize(slackEvent, out _));