private Message ReceiveMessage() { try { return((Message)BFormatter.Deserialize(TcpClient.GetStream())); } catch (Exception) { Console.WriteLine(@"Disconnecting"); Stop(); return(null); } }
private Message ReceiveMessage(TcpClient client) { try { var message = (Message)BFormatter.Deserialize(client.GetStream()); Console.WriteLine("Message received of type: " + message.Type); return(message); } catch (Exception) { client.GetStream().Close(); client.Close(); } return(null); }