Chat Session

LANSA

Chat Session
Example 206 - Rating: specific
The Things that Make Up this ExampleTo Execute this Example

This example shows a Chat Session which uses data queues on the iSeries to send messages between instances of a Visual LANSA form.

The example has two VL forms: the Chat Form itself and an Interface Component which contains the method routines and events for information exchange.



On the iSeries two functions are used; one is a controller called the Conversation Manager and the other is a remote procedure for the Interface Component.



The Conversation Manager sits in a job queue managing the data queues, creating an individual data queue for each individual user and transferring data from the input queue to the individual queues. Only one Conversation Manager will be started for all of the users; when each users starts the remote procedure, it checks to see whether the Conversation Manager has been started. If it hasn’t been started, the remote procedure starts it.

The remote procedure for the Interface Component deals with the flow of information to the input queue and from the individual queue back to the Interface Form. The remote procedure is defined as a *HEAVYUSAGE function, which means, in similar manner to the Visual LANSA concept, that the same ‘instance’ of SET206A will be used for the duration of the chat session.

Methods for the Interface Component

NameDescription
StartingEstablish connection with iSeries, set up data queues
SendToOneSend message to specific user
SendToAllSend message to all users.
EndingDisconnect user from iSeries, delete data queue


Events for the Interface Component

NameDescription
ReceiveMsgA new message has been received by the interface
AddUserA new user has joined the chat session
DeleteUserA user has left the chat session

Notes and Suggestions

This example demonstrates how a simple controller can be written in LANSA. This controller can be used to perform more complex operations than the simple chat functions it performs here, and could easily be extended.

Please note:

This function uses the user profile specified during the log on to Visual LANSA as the identifier of the chat user, (not the user profile specified during connect). So if you want to test several users communicating with each other, each must have their own unique Visual LANSA log in user profile.

The default job queue where the Conversation Manager will be run is QINTER. This could be easily modified in S_206F02.

This Example Also Demonstrates:
  • How to use a program in batch to manage communication between instances of a VL form
  • How to use data queues for communication
  • How to connect users of a particular iSeries
This Example Is Useful Because:
  • File I/O's are slow, and because often there are instances where there is no need to store the communciation information. Data queues provide a quick alternative to a file, and once something has been received from a queue it is deleted on that queue, meaning that it is not unnecessaily stored
Keywords
Data Queue Remote Procedure
ChatCALL_SERVER_FUNCTION
ControllerExample 206
Communication