Package com.betfair.cougar.netutil.nio.message

Examples of com.betfair.cougar.netutil.nio.message.RequestMessage


    @Override
    public long sendRequest(byte[] message, ResponseHandler handler) throws IOException {
        if (!broken) {
            long correlationId = correlationIdGenerator.incrementAndGet();
            RequestMessage req = new RequestMessage(correlationId, message);
            callbacks.put(correlationId, new WaitingResponseHandler(getExpiryTime(), handler));

            session.write(req);
            return correlationId;
        }
View Full Code Here


    public void messageReceived(IoSession session, Object message) throws Exception {
        if (message instanceof ResponseMessage) {
            ((IoHandler) session.getAttribute(RequestResponseManager.SESSION_KEY)).messageReceived(session, message);
        }
        else if (message instanceof RequestMessage) {
            RequestMessage req = (RequestMessage) message;

            final CougarObjectOutput out = objectIOFactory.newCougarObjectOutput(new ByteArrayOutputStreamWithIoSession(session, req.getCorrelationId()), CougarProtocol.getProtocolVersion(session));
            final CougarObjectInput in = objectIOFactory.newCougarObjectInput(new ByteArrayInputStream(req.getPayload()), CougarProtocol.getProtocolVersion(session));
            final String remoteAddress = ((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress();
            final SocketTransportCommandImpl command = new SocketTransportRPCCommandImpl(in, out, remoteAddress, session);

            requestsReceived.incrementAndGet();
            processor.process(command);

            sessionLogger.log(ALL, session, "ExecutionVenueServerHandler - Message %s processed", req.getCorrelationId());
        }
        else if (message instanceof EventMessage) {
            EventMessage em = (EventMessage) message;

            final CougarObjectInput in = objectIOFactory.newCougarObjectInput(new ByteArrayInputStream(em.getPayload()), CougarProtocol.getProtocolVersion(session));
View Full Code Here

TOP

Related Classes of com.betfair.cougar.netutil.nio.message.RequestMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.