Beispiel #1
0
        public virtual void SendChar(char c)
        {
            //System.Diagnostics.Debug.WriteLine("SendChar: " + (int) c);
            if (c == (char)8 && BackspaceDeleteMode)
            {
                c = (char)127;
            }

            SendBuffer.Add(c);
            ReadyToSend?.Invoke(this, new EventArgs());
        }
Beispiel #2
0
 /// <summary>
 /// Convert a UTF string to ASCII data and send it to the output port.
 /// </summary>
 /// <param name="Text">Text to transmit</param>
 public virtual void SendString(string Text)
 {
     for (int i = 0; i < Text.Length; i++)
     {
         SendBuffer.Add(Text[i]);
         ReadyToSend?.Invoke(this, new EventArgs());
         while (SendBuffer.Count > 255)
         {
             System.Windows.Forms.Application.DoEvents();
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Send a byte array message to the client.
        /// </summary>
        /// <param name="ByteArray">The message to send to the client.</param>
        public async Task SendBytes(byte[] ByteArray)
        {
            var outBuffer = new ArraySegment <byte>(ByteArray);

            SendBuffer.Add(outBuffer);
            if (SendBuffer.Count > 1)
            {
                return;
            }
            while (SendBuffer.Count > 0)
            {
                var segment = SendBuffer[0];
                await ClientSocket.SendAsync(segment, WebSocketMessageType.Text, true, CancellationToken.None);

                SendBuffer.Remove(segment);
            }
        }