/** Constructs a new RTMPTConnection */ RTMPTConnection() { super(IConnection.Type.POLLING.name().toLowerCase()); // create a DummySession for the HTTP-based connection to allow our Mina based system happy ioSession = new DummySession(); ioSession.setAttribute(RTMPConnection.RTMP_SESSION_ID, sessionId); }
public void flush(AbstractIoSession session) { DummySession s = (DummySession) session; WriteRequest req = s.getWriteRequestQueue().poll(session); // Chek that the request is not null. If the session has been closed, // we may not have any pending requests. if (req != null) { Object m = req.getMessage(); if (m instanceof FileRegion) { FileRegion file = (FileRegion) m; try { file.getFileChannel().position(file.getPosition() + file.getRemainingBytes()); file.update(file.getRemainingBytes()); } catch (IOException e) { s.getFilterChain().fireExceptionCaught(e); } } getFilterChain().fireMessageSent(req); } }
setAttributeMap(factory.getAttributeMap(this)); setWriteRequestQueue(factory.getWriteRequestQueue(this)); } catch (Exception e) { throw new InternalError();
/** * {@inheritDoc} */ @Override public void flush(IoSession session) { DummySession s = (DummySession) session; WriteRequest req = s.getWriteRequestQueue().poll(session); // Chek that the request is not null. If the session has been closed, // we may not have any pending requests. if (req != null) { Object m = req.getMessage(); if (m instanceof FileRegion) { FileRegion file = (FileRegion) m; try { file.getFileChannel().position(file.getPosition() + file.getRemainingBytes()); file.update(file.getRemainingBytes()); } catch (IOException e) { s.getFilterChain().fireExceptionCaught(e); } } getFilterChain().fireMessageSent(req); } }
setAttributeMap(factory.getAttributeMap(this)); setWriteRequestQueue(factory.getWriteRequestQueue(this)); } catch (Exception e) { throw new InternalError();
/** * {@inheritDoc} */ @Override public void flush(IoSession session) { DummySession s = (DummySession) session; WriteRequest req = s.getWriteRequestQueue().poll(session); // Chek that the request is not null. If the session has been closed, // we may not have any pending requests. if (req != null) { Object m = req.getMessage(); if (m instanceof FileRegion) { FileRegion file = (FileRegion) m; try { file.getFileChannel().position(file.getPosition() + file.getRemainingBytes()); file.update(file.getRemainingBytes()); } catch (IOException e) { s.getFilterChain().fireExceptionCaught(e); } } getFilterChain().fireMessageSent(req); } }
setAttributeMap(factory.getAttributeMap(this)); setWriteRequestQueue(factory.getWriteRequestQueue(this)); } catch (Exception e) { throw new InternalError();
private <R extends Response> R retrySync(Request aRequest) throws Exception { RequestEnvelope requestEnv = new RequestEnvelope(aRequest, null, null, sessionTicket, null); Logger.getLogger(PlatypusPlatypusConnection.class.getName()).log(Level.FINE, "{0} is connecting to {1}:{2}.", new Object[]{Thread.currentThread().getName(), host, port}); if (!syncSocket.isConnected()) { syncSocket.connect(new InetSocketAddress(host, port)); } Logger.getLogger(PlatypusPlatypusConnection.class.getName()).log(Level.FINE, "{0} is connected to {1}:{2}.", new Object[]{Thread.currentThread().getName(), host, port}); SyncProtocolEncoderOutput requestOut = new SyncProtocolEncoderOutput(); syncEncoder.encode(null, requestEnv, requestOut); Object oFiltered = requestOut.getFiltered(); OutputStream os = syncSocket.getOutputStream(); IoBuffer toWrite = (IoBuffer) oFiltered; os.write(toWrite.array()); byte[] readBuffer = new byte[1024 * 16]; ByteArrayOutputStream accumulated = new ByteArrayOutputStream(); InputStream is = syncSocket.getInputStream(); int read = 0; while (read > -1) { read = is.read(readBuffer); accumulated.write(readBuffer, 0, read); SyncProtocolDecoderOutput responseOut = new SyncProtocolDecoderOutput(); IoSession session = new DummySession(); session.setAttribute(RequestEnvelope.class.getSimpleName(), requestEnv); if (syncDecoder.doDecode(session, IoBuffer.wrap(accumulated.toByteArray()), responseOut)) { sessionTicket = requestEnv.ticket; return (R) responseOut.getFiltered(); } } throw new Exception("No response was recieved via platypus protocol"); }