Esempio n. 1
0
        private async Task SendGroupActionAndWaitForAck(string connectionId, string groupName, GroupAction action)
        {
            var id  = Interlocked.Increment(ref _InternalId);
            var ack = _ackHandler.CreateAck(id);

            RabbitMQGroupCommand command = new RabbitMQGroupCommand(id, action, this._QueueName, groupName, connectionId);

            await SendGroupManagement(command);

            await ack;
        }
Esempio n. 2
0
 public async Task SendGroupManagement(RabbitMQGroupCommand command)
 {
     await Task.Run(() =>
     {
         var message    = _Protocol.WriteGroupCommand(command);
         var properties = new BasicProperties
         {
             Headers = new Dictionary <string, object>
             {
                 { "channel", RabbitMQChannel.GroupCommand },
                 { "channelId", command.ConnectionId }
             }
         };
         _PublishModel.BasicPublish(_RabbitMQOptions.ExchangeName, "", properties, message);
     });
 }
        public byte[] WriteGroupCommand(RabbitMQGroupCommand command)
        {
            var writer = MemoryBufferWriter.Get();

            try
            {
                MessagePackBinary.WriteArrayHeader(writer, 5);
                MessagePackBinary.WriteInt32(writer, command.Id);
                MessagePackBinary.WriteString(writer, command.ServerName);
                MessagePackBinary.WriteByte(writer, (byte)command.Action);
                MessagePackBinary.WriteString(writer, command.GroupName);
                MessagePackBinary.WriteString(writer, command.ConnectionId);

                return(writer.ToArray());
            }
            finally
            {
                MemoryBufferWriter.Return(writer);
            }
        }