Exemplo n.º 1
0
        /// <summary>
        /// Sends a free-form, unsafe packet in JSON format.
        /// </summary>
        /// <param name="json">JSON packet string to be sent.</param>
        /// <remarks>Make sure the packet is WELL formed. Otherwise client will certainly get disconnected.</remarks>
        public void SendJson(string json)
        {
            if (IsReady && IsOpen)
            {
                WebSocket.Send(json);
            }

            var eventArgs = new JsonEventArgs(json);

            JsonWrite?.Invoke(this, eventArgs);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends a predefined, tested and safe packet.
        /// </summary>
        /// <param name="packet">Packet to be sent.</param>
        public void SendPacket(Packet packet)
        {
            if (IsReady && IsOpen)
            {
                WebSocket.Send(packet);
            }

            var eventArgs = new JsonEventArgs(packet);

            JsonWrite?.Invoke(this, eventArgs);
        }