Beispiel #1
0
        public void WriteMessage(IMessageLite request)
        {
            var bytes = request.ToByteArray();
            var cos   = CodedOutputStream.CreateInstance(TcpClientWrapper.GetStream());

            cos.WriteRawVarint64((ulong)bytes.Length);
            cos.Flush();
            TcpClientWrapper.GetStream().Write(bytes, 0, bytes.Length);
            TcpClientWrapper.GetStream().Flush();
        }
        public void WriteMessage(IMessage request)
        {
            var bytes = request.ToByteArray();
            var cos   = new CodedOutputStream(TcpClientWrapper.GetStream());

            cos.WriteUInt64((ulong)bytes.Length);
            cos.Flush();
            TcpClientWrapper.GetStream().Write(bytes, 0, bytes.Length);
            TcpClientWrapper.GetStream().Flush();
        }
 public void Process()
 {
     using (var inputStream = tcpClient.GetStream())
         using (var outputStream = streamFactory.GetStreamWriterWrapper(inputStream))
         {
             try
             {
                 ParseRequest(inputStream);
                 ReadHeaders(inputStream);
                 if (httpMethod.Equals("GET"))
                 {
                     HandleGETRequest();
                 }
                 else if (httpMethod.Equals("POST"))
                 {
                     HandlePOSTRequest(inputStream, outputStream);
                 }
             }
             catch (Exception e)
             {
                 Console.WriteLine(e.Message);
                 WriteFailure(outputStream);
             }
         }
     tcpClient.Close();
 }
Beispiel #4
0
        /// <summary>
        /// Handles a successful connection to an IRC server. Completes the
        /// connection by sending registration information.
        /// </summary>
        /// <param name="info">The registration info used to register with the server</param>
        internal virtual async Task HandleConnectionAsync(RegistrationInformation info)
        {
            _clientStream = _client.GetStream();
            _reader       = new StreamReader(_clientStream, Encoding.Default);

            IsConnected = true;

            await SendRegistrationInfoAsync(info);

            BeginReadAsync();
        }