This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes how to organize i/o communication between a controller and i/o class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how to organize i/o communication between a controller and i/o class" Watch "how to organize i/o communication between a controller and i/o class" New topic
Author

how to organize i/o communication between a controller and i/o class

Piter Smith
Ranch Hand

Joined: Feb 25, 2009
Posts: 31
(Keep in mind that the i/o is using Apache TelnetClient, not because I want to use Telnet, but because that's a MUD game requirement. Not all MUD' s support ssh -- and probably never will.)


Surely there must be a cleaner way of sending data about. This is a basic type MUD game client, similar to Mudlet, but in Java, for MUD games.

Mudlet aliasing scripting is here:

http://wiki.mudlet.org/w/Manual%3aScripting#How_to_highlight_my_current_target.3F

which I'm trying to implement in Java.



The i/o problem is four fold fold. Basics:

capture keyboard input with the read thread (local input)
capture and print an InputStream with the readInput thread (remote output from the game server)


Additionally, the input thread will also capture "alias" type commands, ie any keyboard entry starting with a special character is an "alias" for the client, a message to the client. This is in the read thread.

Also, the readInput thread will send each line off for processing for "triggers" with regex.

The above is just a very basic MUD client.


However, the input/output seems amazingly messy and difficult to follow. There are some definite kludges in capturing the "aliases", special commands, in the read thread, so that I can clean up a bit. In general, it's just quite difficult to follow. What are some sort of things I can do to make this easier to read, and maybe a better design?







The current package structure:


src/
├── connection.properties
├── player
│   ├── Flag.java
│   ├── GameAction.java
│   ├── GameData.java
│   └── TelnetEventProcessor.java
└── telnet
├── Alias.java
├── AliasTarget.java
├── InputOutput.java
├── Logic.java
├── PropertiesReader.java
└── TelnetConnection.java





TelnetConnection is the controller and InputOutput is, of course, the i/o. These two classes seem very clumsy, and I would like to break them up into smaller pieces, smaller classes, which just do one thing and do that one thing in an easy to see way. But breaking i/o in "input" and "output" seems a bit silly. Surely there's an organziational problem?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to organize i/o communication between a controller and i/o class
 
Similar Threads
cannot process web form.
Not Sure
ANSI to plain text for regex
Write a program that reads and writes from binary or text files
File Letter Counter help