Dynamic View Services > Implementing a Dynamic View Server and its Components > Overview > Managing Connections and Installing an Encoder/Decoder
 
Managing Connections and Installing an Encoder/Decoder
When subclassing IlsMvServer, you can override the member functions IlsMvServer::onConnect and IlsMvServer::onDisconnect to handle connection and disconnection by the components through the function IlsMvComponent::Connect.
You can also install a request encoder/decoder on a connection. To do so, use the member functions IlsMvEndPoint::setEncoder and IlsMvEndPoint::setDecoder. These method should be called as soon as the connection has been established, before any messages have been exchanged.
Server Side
On the server side, first override the member function IlsMvServer::acceptConnection, then invoke either of the setEncoder or setDecoder methods from that overriden version. For example:
// virtual
IlsBoolean
MyServer::acceptConnection(IlsMvComponentItf& itf, IlsString& cause)
{
itf.setEncoder(Encode);
itf.setDecoder(Decode);
return IlsTrue;
}
Component Side
On the component side, you must install a corresponding decoder and encoder to handle the messages received and sent by the component, and you must do so when the virtual member function IlsMvComponent::onConnect is called. You should subclass IlsMvComponent and redefine this method:
// virtual
void
MyComponent::onConnect()
{
setEncoder(Encode);
setDecoder(Decode);
}
These encoder and decoder will be used by the underlying communication classes for each outgoing and incoming message exchanged with this component. This API allows you to install encryption or compression mechanisms on the connection.

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.