|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.genesyslab.platform.commons.protocol.AbstractChannel
com.genesyslab.platform.commons.protocol.ServerChannel
com.genesyslab.platform.openmedia.protocol.InteractionServerProtocolListener
public class InteractionServerProtocolListener
Use InteractionServerProtocolListener
object as a server for InteractionServerProtocol
.
Note, that
// Example of using
InteractionServerProtocolListener
.
import com.genesyslab.platform.openmedia.protocol.InteractionServerProtocol;
import com.genesyslab.platform.openmedia.protocol.InteractionServerProtocolListener;
import com.genesyslab.platform.openmedia.protocol.interactionserver.events.EventAck;
import com.genesyslab.platform.openmedia.protocol.interactionserver.requests.RequestRegisterClient;
import com.genesyslab.platform.commons.protocol.Message;
import com.genesyslab.platform.commons.protocol.Endpoint;
import com.genesyslab.platform.commons.protocol.Referenceable;
import com.genesyslab.platform.commons.protocol.RequestContext;
import com.genesyslab.platform.commons.protocol.WildcardEndpoint;
import com.genesyslab.platform.commons.protocol.ProtocolException;
import com.genesyslab.platform.commons.protocol.ClientRequestHandler;
public class testIxn {
public static void main(final String[] args)
throws ProtocolException, IllegalStateException, InterruptedException {
final int PORT = 11111;
final InteractionServerProtocolListener server = new InteractionServerProtocolListener(new WildcardEndpoint(PORT));
server.setClientRequestHandler(new ClientRequestHandler() {
public void processRequest(final RequestContext requestContext) {
Message msg = requestContext.getRequestMessage();
Message response = null;
Object refId = null;
if (msg instanceof Referenceable) {
refId = ((Referenceable) msg).retreiveReference();
}
if (msg != null) {
if (msg.messageId() == RequestRegisterClient.ID) {
RequestRegisterClient request = (RequestRegisterClient) msg;
EventAck event = EventAck.create();
event.setProxyClientId(1);
response = event;
} else if (msg.messageId() == Request*.ID) { // handle some request
// ...
// create response
}
}
if (response != null) {
if (refId != null && response instanceof Referenceable) {
((Referenceable) response).updateReference(refId);
}
try {
requestContext.respond(response);
} catch (final ProtocolException e) {
e.printStackTrace();
}
}
}
});
server.open();
InteractionServerProtocol client = new InteractionServerProtocol(new Endpoint("localhost", PORT));
client.open();
// create "some request":
Request* request = Request*.create();
request.set*(*);
Message response = client.request(request);
// ...
client.close();
server.close();
}
}
ServerChannel
adds ADDP support for incoming connections by default, if no protocol name option is specified.
The AddpInterceptor.ACTIVE_KEY
option always set to false, because it is client channel responsibility to initiate ADDP.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel |
---|
AbstractChannel.AsyncErrorNotifier |
Field Summary |
---|
Fields inherited from interface com.genesyslab.platform.commons.protocol.Channel |
---|
DEFAULT_TIMEOUT, INFINITE_TIMEOUT |
Fields inherited from interface com.genesyslab.platform.commons.protocol.Receiver |
---|
DEF_INPUT_SIZE |
Constructor Summary | |
---|---|
InteractionServerProtocolListener(Endpoint endpoint)
|
Method Summary |
---|
Methods inherited from class com.genesyslab.platform.commons.protocol.ServerChannel |
---|
addListener, applyConfiguration, beginClose, beginOpen, clearInput, close, close, closeClientChannels, closeListener, getChannels, getInputSize, getLocalEndPoint, getProtocolDescription, getProtocolFactory, modifyNewChannel, open, open, receive, receive, receiveRequest, receiveRequest, releaseReceivers, removeListener, resetReceiver, send, sendToChannelsExcept, sendToChannelsExcept, setClientRequestHandler, setInputSize, setReceiver |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.genesyslab.platform.commons.protocol.Channel |
---|
getTimeout, setTimeout |
Methods inherited from interface com.genesyslab.platform.commons.protocol.AsyncChannel |
---|
getState |
Methods inherited from interface com.genesyslab.platform.commons.protocol.ChannelListenerSupport |
---|
addChannelListener, removeChannelListener |
Methods inherited from interface com.genesyslab.platform.commons.protocol.EndpointSupport |
---|
getEndpoint, setEndpoint |
Methods inherited from interface com.genesyslab.platform.commons.protocol.ConfigurationSupport |
---|
configure, getConfiguration |
Constructor Detail |
---|
public InteractionServerProtocolListener(Endpoint endpoint)
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |