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

How to code a service?

UbiquiTalk services should be implemented only on the host. When needed, clients will download required code in order to execute the service.

Three steps are required for coding a service:
  1. Implement client classes
  2. Implement service support classes
  3. Implement service facade class

In the follwing we present step by step the implementation of a Hello Service. The goal of this service is to allow the client to display 'Hello World!' on the Transcript of the image hosting the service.

Implement client classes

To code the service, we first focus on client class(es). They should be put in a dedidcated monticello package or in a dedicated class category. Our example has a single client class that we put in the class category 'UTHelloWorld-Client'.

Object subclass: #UTHelloClient
InstanceVariableNames: ‘’
ClassVariableNames: ‘’
PoolDictionaries: ‘’
Category: ‘UTHelloWorld-Client’

This class contains only a single class method which is the entry point for the service.

printHelloOnService: helloService
 helloService printHello

Implement service support classes

We also need to implement classes necessary to the service. For Hello World service, we use the Transcript. The supporting class (TranscriptStream) is already available. So, we have nothing to do for this part.

Implement service facade class

last but not the least, the service’s class. It must inherit from UTService and implement a few methods.

Service class

UTService subclass: #UTHelloService
instanceVariableNames: ‘’
classVariableNames: ‘’
poolDictionaries: ‘’
category: ‘UTHelloWorld-Service’ 

Service method

 Transcript cr; show: ‘Hello World !’

Service description methods

 ^‘Hello World service’

 ^'Prints ''Hello World!'' on a remote Transcript'

Client management methods

clientPackageNameFor: anUTHost 
 "Return the name of the category or Monticello package which contains client code"

hasClientCodeFor: aHost
 "Boolean. Possess client code"

clientStartupReceiverFor: aHost
 "Indicate the name of remote client object"
 ^UTRemoteGlobalObject named: UTHelloClient

clientStartupSelectorFor: aHost
 "Return the name of class method to execute at client side"

clientStartupArgumentsFor: aHost
 "Return arguments used by this method contained in an Array"

UTService class implements two methods that subclasses may optionally implement : startUp and shutdown. Those methods are executed each time UbiquiTalk is started and stopped. Some services need to perform specific initialize and cleanup actions. For example a chat conference service must empty its chatters set on shutdown to avoid failures due to references on unavailable remote chatters.

UTService subclass: #UTConference
..."rest of class definiont"
 "Clear the chatter list when the host is shut down. Done in order to avoid failures when disconnection occurs"
 chatters := Set new.