/// <summary>
        /// Sends Pings with the specified <paramref name="message"/> to all clients of the WebSocket
        /// services provided by a WebSocket server.
        /// </summary>
        /// <returns>
        /// A Dictionary&lt;string, Dictionary&lt;string, bool&gt;&gt; that contains the collection of
        /// service paths and pairs of session ID and value indicating whether each WebSocket service
        /// received a Pong from each client in a time.
        /// If <paramref name="message"/> is invalid, returns <see langword="null"/>.
        /// </returns>
        /// <param name="message">
        /// A <see cref="string"/> that contains a message to broadcast.
        /// </param>
        public Dictionary <string, Dictionary <string, bool> > Broadping(string message)
        {
            if (message == null || message.Length == 0)
            {
                return(Broadping());
            }

            byte [] data = null;
            var     msg  = _state.CheckIfStarted() ??
                           (data = Encoding.UTF8.GetBytes(message)).CheckIfValidPingData();

            if (msg != null)
            {
                _logger.Error(msg);
                return(null);
            }

            return(broadping(WsFrame.CreatePingFrame(Mask.UNMASK, data).ToByteArray(), 1000));
        }
        /// <summary>
        /// Sends Pings with the specified <paramref name="message"/> to all clients
        /// of the WebSocket service.
        /// </summary>
        /// <returns>
        /// A Dictionary&lt;string, bool&gt; that contains the collection of pairs of
        /// session ID and value indicating whether the WebSocket service received a
        /// Pong from each client in a time.
        /// </returns>
        /// <param name="message">
        /// A <see cref="string"/> that represents the message to send.
        /// </param>
        public Dictionary <string, bool> Broadping(string message)
        {
            if (message == null || message.Length == 0)
            {
                return(Broadping());
            }

            byte [] data = null;
            var     msg  = checkIfCanSend(
                () => (data = Encoding.UTF8.GetBytes(message))
                .CheckIfValidControlData("message"));

            if (msg != null)
            {
                _logger.Error(msg);
                return(null);
            }

            return(Broadping(
                       WsFrame.CreatePingFrame(Mask.UNMASK, data).ToByteArray(), 1000));
        }
Exemple #3
0
        public Dictionary <string, bool> Broadping(string message)
        {
            if (message == null || message.Length == 0)
            {
                return(this.Broadping());
            }
            byte[] data = null;
            string text;

            if ((text = this._state.CheckIfStart()) == null)
            {
                text = (data = Encoding.UTF8.GetBytes(message)).CheckIfValidControlData("message");
            }
            string text2 = text;

            if (text2 != null)
            {
                this._logger.Error(text2);
                return(null);
            }
            return(this.Broadping(WsFrame.CreatePingFrame(Mask.Unmask, data).ToByteArray(), 1000));
        }