Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9126301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:00:35+00:00 2026-06-17T07:00:35+00:00

I have a card game program, and so far, the chat works great back

  • 0

I have a card game program, and so far, the chat works great back and forth over the TCPClient streams between host and client. I want to make it do this with serializing and deserializing so that I can also pass cards between host and client. I tried to create a separate TCPClient stream for the passing of cards but it didn’t work and figured it may be easier to keep one TCPClient stream that gets the text messages as well as cards. So I created a class, called cereal, which has the properties for the cards that will help me rebuild the card from an embedded database of cards on the other end. Is there a way to make my program figure out whether a card has been put in the stream or if it’s just text in the stream so I can properly deserialize it to a string or to a cereal? Or should I add a string property to my cereal class and when that property is filled in after deserializing to the cereal, i’ll know it’s just text (if that field is empty after deserializing i’ll know it’s a card)? I’m thinking a try catch, where it tries to deserialize to a string, and if it fails it will catch and cast as a cereal. Or am I just way off base with this and should choose another route? I’m using visual studio 2011, am using a binaryformatter, and am new to serializing/deserializing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:00:36+00:00Added an answer on June 17, 2026 at 7:00 am

    Ended up creating a container class which is serializeable. If I am sending text to the other computer, I set the text property of the container to whatever the text is. Then when this container is received, if it has text, the receiving computer will display the text. If the received container contains a card, it will create the card and put it where it needs to go based on additional properties found in the received container. If it is a discard, then it finds the card based on additional properties in the container, and discards it to the correct pile. I also included a command as String property in the container, so if all other properties are false, it will see if the command property has a string or not. If so, calls the command received method and finds the correct command and executes the code. Works great so far.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that currently works as a chat server. It's a turn
I am trying to write a program to simulate a card game. I have
I have a card game program that when a card gets discarded and is
I have been developing a game basic card game for Android. At the moment
I am making a card game in ruby. I have the Game class, which
I have a card game where the cards are represented as a layout object
I have a card-game application which makes use of Single Table Inheritance. I have
I have a card game I created in android and it is possible to
I currently have a multiplayer card game developed and working in Java and it
So, i'm attempting simple card game. I have player class with draw function, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.