BlottoBeats.Library.Networking.BBServerConnection.SendRequest C# (CSharp) Method

SendRequest() public method

Sends a BBRequest to the server
public SendRequest ( BBRequest request ) : BBResponse
request BBRequest The BBRequest to send
return BBResponse
        public BBResponse SendRequest(BBRequest request)
        {
            object reply;

            using (TcpClient client = new TcpClient()) {
                client.Connect(serverEndPoint);
                NetworkStream networkStream = client.GetStream();

                Message.Send(networkStream, request);
                reply = Message.Recieve(networkStream);
            }

            if (reply == null)
                throw new Exception("BBRequest Error: Expected reply but recieved none");//Console.Error.WriteLine("BBRequest Error: Expected reply but recieved none");
            else
                return reply as BBResponse;
        }