4. Simple Chat
As chat applications go, SimpleChat is very limited. A chat allows two people to exchange messages in a single text box each. There is no history: you enter text, your chat partner types a reply in his text box and you replace your text by a new reaction.
Click the home button and move to the tab Start contexts
. You’ll see a new row now. Double click on the Simple Chat App
row to open that context.
Important
|
Screens in MyContexts are either hand-crafted, or automatically generated. Most of the screens you’ll see during this tutorial fall in the latter category. Invariably, a screen that displays a context will have a row of tabs (possibly one, like the Chats screen you’re watching now). Each tab shows one or more perspectives your role in this context has on other roles. |
The role you play in the My Chats context has a perspective on a role called Chats and a role called Incoming Chats. Open the Chats
tab. Two empty tables appear. The first is the list of Chats that you manage. Click the plus icon on the table control bar. A menu drops down showing a single item: model://perspectives.domains#SimpleChat$Chat
.
Note
|
model://perspectives.domains#SimpleChat$Chat is what is called a fully qualified name. It has a namespace part (model://perspectives.domains@SimpleChat), separated by a $-sign from a role name. From time to time such elaborate names will crop up. This is a sign of the development state that MyContexts is in: eventually, such names are to be replaced by readable names. In this case, just simply Chats .
|
4.1. Creating contexts
Now click the item model://perspectives.domains#SimpleChat$Chat
. A row appears in the table, without any text in it. Double-click it. A new screen appears, to show the context you’ve just created: an instance of Chat. Let’s take some time to get familiar with this screen.
-
The upper text field displays the title of the Chat (none, currently)
-
The middle area is divided into two columns, titled
This chat’s partner
andYour contacts
respectively. -
At the bottom we find a check box with the text
I want to invite someone I have no contact card for
.
Click the title field and enter the text "My first chat!" in it. Immediately, this text is repeated at the top of the screen.
For now, there is little we can do as you have no peers yet whose contact card you could have used to set up a chat. We will return to this screen later in the tutorial, when you have the means to actually invite someone to chat.
Click the browser’s back button (or hit the key combination that will make it navigate backwards, or any other means to make your browser revisit the previous page it displayed in this browser tab or window). You will return to the My Chats context, that you left when you double-clicked the chat you created.
Important
|
Each time MyContexts displays a new context, it adds the previous context to the browse history. Even though the screens do not come from some server but are created by MyContexts locally, you can navigate back and forth through this history with the functions that your browser offers. |
Remember that generated screens have a row of tabs. When navigating back, no tab is open. Open the Chats
tab now. The row you have created before now has text content: the chat’s name you entered.
4.2. Removing contexts
Let’s do this again: create a new chat, open it, name it "My second chat" and navigate back to this list of chats. If you were succesful, you’ll now see two rows in the table of chats. Time to remove one: select one row by clicking in it and hit the backspace key. A modal dialog will show, whose body text reads: Do you want to remove the context that fills the role as well?.
This calls for some explanation. The Chats table lists the Chat contexts that you have created (and in the future you’ll see it will also show Chats that others have created and invited you in). Remember that the screen that contains this table displays the context My Chats. So we look at contexts (individual Chats) that are somehow embedded in a context. A context just has role instances, but it is possible to fill a particular type of role with contexts. We might say that contexts are bonded together through roles. So, really, the table does not display contexts directly: it lists the roles that are filled with contexts.
If this explanation left you reeling, don’t worry. For most practical purposes you can just pretend such tables list contexts. But it explains the question on the model dialog.
For now, click Yes
. The selected row disappears; a notification tells you that the Chat with that title has been removed.