Revision: 229 http://skycastle.svn.sourceforge.net/skycastle/?rev=229&view=rev Author: zzorn Date: 2007-10-06 23:06:42 -0700 (Sat, 06 Oct 2007) Log Message: ----------- Started implementing the core, based on irc discussion and documentation on wiki page: http://www.skycastle.org/wiki/Skycastle_Protocol#Semantic_level Added Paths: ----------- trunk/skycastle/modules/core/src/main/java/ trunk/skycastle/modules/core/src/main/java/org/ trunk/skycastle/modules/core/src/main/java/org/skycastle/ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Action.java trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ActionRequest.java trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Actor.java trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Controller.java trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ParameterMetadata.java trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Parameters.java trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensation.java trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensor.java trunk/skycastle/modules/core/src/main/java/org/skycastle/core/package.html trunk/skycastle/modules/core/src/test/java/ Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Action.java =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Action.java (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Action.java 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,28 @@ +package org.skycastle.core; + +/** + * Something that an {@link Actor} can do. Allows {@link Controller}s of an Actor that has the action to invoke it. + * Takes some number of parameters with some values (can be structured values, like lists). + * <p/> + * Also holds parameter metadata for the {@link ActionRequest}s. + */ +public interface Action +{ + /** + * @return identifier of this action. + */ + String getIdentifier(); + + /** + * @return metadata for this action, describes the parameters accepted by it. + */ + ParameterMetadata getMetadata(); + + /** + * Execute this action for the specified {@link Actor}. + * + * @param actor the actor that is executing this action. + * @param parameters the parameters for this action. + */ + void execute( Actor actor, Parameters parameters ); +} Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Action.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ActionRequest.java =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ActionRequest.java (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ActionRequest.java 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,21 @@ +package org.skycastle.core; + +/** + * A request to execute a particular {@link Action}, with some specified parameters. + * <p/> + * Sent by a {@link Controller} to an {@link Actor} it has control over. + */ +public interface ActionRequest +{ + /** + * @return the identifier of the {@link Action} that was requested, in the target {@link Actor}. + */ + String getActionIdentifier(); + + /** + * @return the parameters for this ActionRequest. + */ + Parameters getParametes(); + +} + Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ActionRequest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Actor.java =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Actor.java (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Actor.java 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,66 @@ +package org.skycastle.core; + +import java.util.Collection; +import java.util.Map; + +/** + * Something that can do {@link Action}s, and can have {@link Sensor}s, and can have control over other {@link Actor}s. + */ +// REFACTOR: Maybe rename to something else, Actor is a bit close to Action, but Actor really also has Sensors and other controlled Actors. +// Maybe something that is similar to Controller? Controllable? Controlled? +// Or just descriptive, like Avatar or Agent (is there something not starting with an a?) +// Or maybe it could be Entity? That would also make it more straightforward for the action to get access to all the data it needs. + +// IDEA: Different Controllers might have different access levels to the Actor, so we should perhaps +// supply a reference to the (originating?) controller when making requests? +// Or is it up to the controller to keep track of what it has access to? +// For now the interface might be a bit more stable if we tell the controller also when we do an actionRequest (less need to add more parameters later). +public interface Actor +{ + /** + * Called when the specified controller is requesting the specified action. + * + * @param controller the controller that requested the action. Could be used for access screening or such purposes. + * @param subActorId the id of an actor controlled by this actor that the action should be sent to, + * or an empty string if it is sent to this actor. + * @param actionRequest the request that was made. Contains the action id and parameters. + */ + void requestAction( Controller controller, String subActorId, ActionRequest actionRequest ); + + /** + * Subscribes the specified {@link Controller} to recieve {@link Sensation}s from the specified {@link Sensor}. + * + * @param controller the controller to subscribe. Should not be null. + * @param subActorId the id of an actor controlled by this actor that the subscription should be sent to, + * or an empty string if it is sent to this actor. + * @param sensorId the identifier of the sensor to subscribe to. + */ + // IDEA: We could maybe support filters later, e.g. recieve only the Sensations where the 'channel' parameter is 'SystemMessages'. For now it is overkill. + void subscribeToSensor( Controller controller, String subActorId, String sensorId ); + + /** + * Unsubscribes the specified {@link Controller} so that it no longer recieves {@link Sensation}s from the specified {@link Sensor}. + * + * @param controller the controller to unsubscribe. Should not be null. + * @param subActorId the id of an actor controlled by this actor that the unsubscription should be sent to, + * or an empty string if it is sent to this actor. + * @param sensorId the identifier of the sensor to unsubscribe from. + */ + void unsubscribeFromSensor( Controller controller, String subActorId, String sensorId ); + + /** + * @return A read only list with the {@link Sensor}s in this Actor. + */ + Collection<Sensor> getSensors(); + + /** + * @return A read only list with the {@link Action}s in this Actor. + */ + Collection<Action> getActions(); + + /** + * @return A read only map with the {@link Actor}s controlled by this Actor, and their identifiers. + */ + // CHECK: Should we use some global ID:s for Actors, so that we could just return a list of them? But a client might be connected to multiple servers.. + Map<String, Actor> getControlledActors(); +} Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Actor.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Controller.java =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Controller.java (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Controller.java 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,42 @@ +package org.skycastle.core; + +/** + * Something that is controlling an {@link Actor}- can be a player client, a server side AI, or another Actor. + * <p/> + * The Controller can invoke {@link Action}s and receive {@link Sensation}s from the Actor. + */ +public interface Controller +{ + /** + * Called when the controller recieves a {@link Sensation} from some {@link Sensor} that it is subscribed to. + * + * @param actorId either the ID of the {@link Actor} that the {@link Sensor} is in, that is directly controlled by this controller, + * or a dot separated list of Actor ID:s, denoting a path from a directly controlled Actor to some Actor it controls. + * This is the avatar that originated the Sensation. + * @param sensorId the identifier of the {@link Sensor} that the {@link Sensation} is comong from. + * @param sensation the perception coming from the sensor. Can contain many parametes with values. + */ + void sensation( String actorId, String sensorId, Sensation sensation ); + + /** + * Called when the Controller is subscribed to a {@link Sensor}. + * + * @param actorId either the ID of the {@link Actor} that the {@link Sensor} is in, that is directly controlled by this controller, + * or a dot separated list of Actor ID:s, denoting a path from a directly controlled Actor to some Actor it controls. + * @param sensorId the identifier of the {@link Sensor} that the Controller was subscribed to. + * @param parameterMetadata metadta describing the {@link Sensation}s coming from this {@link Sensor}. + */ + void onSubscription( String actorId, String sensorId, ParameterMetadata parameterMetadata ); + + /** + * Called when the controller has been unsubscribed from some {@link Sensor}. + * <p/> + * The Controller may get unsubscribed if it no longer has access rights to the {@link Sensor}, + * or if it unsubscribes itself, or if the network link dies. + * + * @param actorId either the ID of the {@link Actor} that the {@link Sensor} is in, that is directly controlled by this controller, + * or a dot separated list of Actor ID:s, denoting a path from a directly controlled Actor to some Actor it controls. + * @param sensorId the identifier of the {@link Sensor} that the Controller was unsubscribed from. + */ + void onUnsubscription( String actorId, String sensorId ); +} Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Controller.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ParameterMetadata.java =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ParameterMetadata.java (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ParameterMetadata.java 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,12 @@ +package org.skycastle.core; + +/** + * Metadata about {@link Action} or {@link Sensor} {@link Parameters}, sent in {@link ActionRequest}s and {@link Sensation}s. + * <p/> + * Contain things like types, as well as user readable descriptions. + * <p/> + * Can also be used to validate that a specific {@link Parameters} instance has the right structure and ranges for values. + */ +public interface ParameterMetadata +{ +} Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/ParameterMetadata.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Parameters.java =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Parameters.java (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Parameters.java 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,13 @@ +package org.skycastle.core; + +/** + * A sequence of string - value pairs, where the value can have an arbitrary data structure, consisting of + * ints, floats, strings, maps, and lists. + * <p/> + * Used for passing parameters in {@link ActionRequest}s and {@link Sensation}s. + * <p/> + * Can be described by and validated against some {@link ParameterMetadata}. + */ +public interface Parameters +{ +} Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Parameters.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensation.java =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensation.java (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensation.java 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,20 @@ +package org.skycastle.core; + +/** + * Produced by a {@link Sensor}, and sent to a {@link Controller}. Has a some number of parameters. + */ +// CHECK: Should we include also the sensor name, and maybe originating actor in this interface? +// Or as parameters to {@link Controller#sensation}? +public interface Sensation +{ + /** + * @return the type of {@link Sensor} that this sensation originated from. + * Can be used on the client side to determine e.g. what kind of UI representation to create. + */ + String getSensorType(); + + /** + * @return the parameters for this sensation. + */ + Parameters getParametes(); +} Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensation.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensor.java =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensor.java (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensor.java 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,39 @@ +package org.skycastle.core; + +/** + * Part of an {@link Actor}. Allows {@link Controller}s of an {@link Actor} to receive some kind of {@link Sensation}s. + * <p/> + * Also holds parameter metadata for the {@link Sensation} messages. + */ +public interface Sensor +{ + /** + * @return identifier of this Sensor. + */ + String getIdentifier(); + + /** + * @return metadata for the {@link Sensation}s sent by this {@link Sensor}, describes the parameters included in them. + */ + ParameterMetadata getMetadata(); + + /** + * Subscribes the specified {@link Controller} to recieve {@link Sensation}s from this {@link Sensor}. + * + * @param controller the controller to subscribe. + * @param actor the {@link Actor} that this Sensor is in. + * @param sensorId the identifier of the sensor in the Actor. + */ + // IDEA: We could maybe support filters later, e.g. recieve only the Sensations where the 'channel' parameter is 'SystemMessages'. For now it is overkill. + void subscribe( Controller controller, Actor actor, String sensorId ); + + /** + * Unsubscribes the specified {@link Controller} so that it no longer recieves {@link Sensation}s from this {@link Sensor}. + * + * @param controller the controller to unsubscribe. + * @param actor the {@link Actor} that this Sensor is in. + * @param sensorId the identifier of the sensor in the Actor. + */ + void unsubscribe( Controller controller, Actor actor, String sensorId ); + +} Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/Sensor.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Added: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/package.html =================================================================== --- trunk/skycastle/modules/core/src/main/java/org/skycastle/core/package.html (rev 0) +++ trunk/skycastle/modules/core/src/main/java/org/skycastle/core/package.html 2007-10-07 06:06:42 UTC (rev 229) @@ -0,0 +1,15 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> +</head> +<body> + +The core package contains the interfaced used to access the server from the client, or more generally, between a {@link Controller} +and an {@link Actor}. This is basically the action handling logic, and sensory perception handling. + +<h2>Related Documentation</h2> + +See <a href="http://www.skycastle.org/wiki/Skycastle_Protocol#Semantic_level";>the protocol documentation on the wiki</a> for an overview. + +</body> +</html> Property changes on: trunk/skycastle/modules/core/src/main/java/org/skycastle/core/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:keywords + Id Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.