-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Orion Framework: Command service #32
Comments
I've implemented a class-based command system in another project. An example command is as follows:
|
Closing this -- we will revisit this in TShock. |
implement a command service which handles commands with parameters that are either invoked by players, the console, or any UI frontend running in Orion.
The basic spec is as follows:
ICommandStreamService
(shared) whose job it is to keep the list of commands, and facilitate the insertion of command handlers at any place in the handler stack, handle the deserialisation of command parameters, and invoke each handler in the listICommandService
whose job it is to yield commands from their method (up to the implementation), and yield the delegates to to theICommandStreamService
A command service implementation idea is listed below:
AttributeCommandService
: Yields command from attributes placed on instance methods:ObjectStream output
Commands must not write to
Console
orPlayer
, instead must write to an object stream passed to the command in its parameters. This is to ensure that objects written as output from the commands are always formatted in a consistent manner.A command may choose to output any object to the output stream, and they are formatted according to the rules of the UI environment which invokes the command. A command may output more than one object to the output stream, which may include one or more exceptions.
For example, a plugin may output an
IEnumerable<>
, which will format as a text table in the console, comma-separated list in the game itself, a HTML table in the web UI, or a JSON array as a REST call. An exception written to the object stream may format as red text in the console, or a callout in HTML, etc.Any .NET type may be written to the object stream, however complex types will be coalesced to
string
before output; implement.ToString()
if you want to summarize a human-friendly representation of a custom object.The text was updated successfully, but these errors were encountered: