Ejemplo n.º 1
0
        public static void Send(this IRoutingIdSocket socket, uint routingId, byte[] data, int length)
        {
            var msg = new Msg();

            msg.InitPool(length);
            msg.RoutingId = routingId;
            data.Slice(0, length).CopyTo(msg);
            socket.Send(ref msg);
            msg.Close();
        }
Ejemplo n.º 2
0
        public static void Send(this IRoutingIdSocket socket, uint routingId, string message)
        {
            var msg = new Msg();

            // Count the number of bytes required to encode the string.
            // Note that non-ASCII strings may not have an equal number of characters
            // and bytes. The encoding must be queried for this answer.
            // With this number, request a buffer from the pool.
            msg.InitPool(SendReceiveConstants.DefaultEncoding.GetByteCount(message));
            msg.RoutingId = routingId;

            // Encode the string into the buffer
            SendReceiveConstants.DefaultEncoding.GetBytes(message, msg);

            socket.Send(ref msg);
            msg.Close();
        }