View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

Chat with GUI and Shared Component Step by Step

As said in the Chat with GUI and Shared Component Specifications the only difference with the previous example is that the Conference Component is shared between the InteractiveChatter Components (2 of them in this example).

1 How to make a Shared Component

1.1 Create a Conference Component

Create a Conference Component in the top-most composite (which creates the InteractiveChatters):
ChatWithGUISharing>>newTemplate
	| chatWithGUITemplate conferenceTemplate |
	chatWithGUITemplate := super newTemplate.
	(chatWithGUITemplate getFcInterface: #'name-controller') setFcName: 'ChatWithGUIExample'.
	conferenceTemplate := ConferenceMaker new newTemplate.

	(chatWithGUITemplate getFcInterface: #'content-controller') 
		addFcSubComponent: (InteractiveChatterMaker new newTemplate: conferenceTemplate);
		addFcSubComponent: (InteractiveChatterMaker new newTemplate: conferenceTemplate).

	^ chatWithGUITemplate

1.2 Add it to the InteractiveChatters

Create a new method #newTemplate: aComponent which will take the conference component as parameter. Then just add this conference to the sub-components of the composite InteractiveChatter and configure the bindings.
InteractiveChatter>>newTemplate: conferenceTemplate
	| interactiveChatterTemplate textDisplayTemplate chatterInputTemplate name |
	interactiveChatterTemplate := super newTemplate.
	textDisplayTemplate := TextDisplayMaker new template.
	chatterInputTemplate := ChatterInputMaker new template.
	interactiveChatterTemplate nameController setFcName: 'InteractiveChatter'.
	"Adding Sub-components to composite"
	interactiveChatterTemplate contentController
		addFcSubComponent: textDisplayTemplate;
		addFcSubComponent: chatterInputTemplate;
		addFcSubComponent: conferenceTemplate.
	"bind the chatterInput template to the conference Interface"
	chatterInputTemplate bindingController
		bindFc: #sendToConference
		to: (conferenceTemplate getFcInterface: #broadcast).
	"bind the conference interface to the TextDisplay template"
	
	conferenceTemplate bindingController
		bindFc: #broadcasts,((1 to: 1000) atRandom asString)
		to: (textDisplayTemplate getFcInterface: #show).
	
	^ interactiveChatterTemplate


Link to this Page