Specification of Chatroom behaviour using Statecharts
|
General Information
GoalsThis assignment will make you familiar with Statechart modelling, simulation, and code synthesis (and a bit of testing). Problem statementIn this assignment, you will design a Statechart model specifying the reactive behaviour of a chat client. Note that incremental development is good practice: start modelling and trying out (after simulation and subsequently, code synthesis) small parts of the desired behaviour (satisfying only some of the requirements) in isolation. These can be saved and loaded later to incremental build the full solution Statechart. The model and its visual representation must both be discussed and included in your report. The application's reactive behaviour (Java code) will be synthesized from the Statechart. (Behaviour) Requirements
Interface: Network
This interface provides access to network functionality.
- in event connected received when the user successfully connects to a server - in event disconnected received when the user successfully disconnects from a server - in event joined received when the user successfully joins a room - in event left received when the user successfully leaves a room - in event receive_message: string received when a user receives a message from the server (if another participant in the room sends a message) - in event alive received when the server sends an "alive" message (response to a "poll") - out event connect: string establish a connection to the server. This event takes 1 parameters: a string detailing the full address of the server ("hostname:port") - out event disconnect disconnect from the server - out event join: integer join a server, identified by an integer - out event leave leave the current room - out event poll poll the server (expects an "alive" reply) - out event send_message: string send a message to the room - operation get_nr_of_servers(): integer returns the number of hardcoded servers of the client - operation get_server(index: integer): string gets the information of the server with the index provided Interface: UI
This interface provides access to user interface functionality.
- in event input: string a keystroke has occurred the event has a single parameter, containing the input character some special characters include backspace (\b) and carriage return (\r) - operation add_message(msg: string, type: string) shows the message in the chat window, with the specified type (as a string, either "info", "local_message", or "remote_message")) - operation append_to_buffer(char: string) adds a string to the input field and visualizes the change - operation remove_last_in_buffer() removes the final character from the input field and visualizes the change - operation clear_input() clears the input field and visualizes the change - operation input_join() color the input field in the 'join' mode - operation input_msg() color the input field in the 'message' mode - operation input_command() color the input field in the 'command' mode - operation get_buffer(): string returns the current content of the input field Interface: util
This interface provides access to utility functions, mainly implementing string operations that are not available in Yakindu.
- operation concatenate(one: string, two: string): string returns the concatenation of the argument strings - operation remove_last_char(inp: string): string removes the last character from the argument string - operation stoi(inp: string): integer if the argument string represents an integer, returns its integer value - operation is_numerical(inp: string): boolean returns true if the argument string represents an integer, else false - operation is_backspace(inp: string): boolean returns true if the argument string is a backspace, else false - operation is_enter(inp: string): boolean returns true if the argument string is a return, else false - operation is_alphanumerical(inp: string): boolean returns true if the argument string is alphanumerical, else false - operation print(inp: string) prints the argument string to the console Starting pointAs you should only focus on the reactive behaviour of the chat client, we have provided a starting point for you, which you can download here. The starting point includes a working chatserver (implemented in Java) and a network client (in Statecharts). Additionally, the binding with the GUI is also provided. To run the example project, import it as an existing project into your Yakindu workspace. Make sure that the configuration of your project is such that one of the two .jar files in the 'lib' folder (depending on your OS) is on the Java build path of your project. Download the correct SWT jar from the Eclipse website. To run the server, run the Server main class (pass as argument in your run configuration a port number, either 8000 or 8001). You should therefore only change the ChatRoom.sct file. It should not be necessary to change the Network, UI, and util interfaces. You might need to add an 'internal' interface for internal bookkeeping. You can download the examples discussed in class (the traffic light) here: https://reactivesystemsmodeling.github.io/ Practical informationModelling of the Statechart model can be done using Yakindu SCT. Follow the installation instructions presented on the website. to install the tool and run it. As this assignment uses a server, you will have to start a server by running the Server main class (which takes as argument a port, for example 8000). You can have multiple servers running, as long as each has a different port. By default, 2 server locations are included in the chat client: localhost port 8000 and 8001. The server will print some information about its communication, so you can see whether or not your calls reach the server. You can run the UI by running the ChatRoomUI main class. To hand in your project, please export it to a zip-file using the functionality that Yakindu (and any Eclipse installation) offers. Also, please include your model as an image in your report. Use the functionality Yakindu offers to export your model to an image. It is good practice to model and simulate different parts of the overall solution in isolation (incremental, bottom-up design). Additionally, while doing this incremental design, test the requirements (using sctunit) as you go along; this ensures your increments are always correct with respect to the requirements you have implemented. You are encouraged to use all functionality that Statecharts offer, such as history states, after events, and orthogonal components.
|