protected final Object next () { try { int total = 0; while (total < chunk.length) { int count = input.read(chunk, total, chunk.length - total); if (count < 0) { if (total == 0) return null; byte[] partial = new byte[total]; System.arraycopy(chunk, 0, partial, 0, total); return next(partial); } total += count; } } catch (IOException ex) { throw new KryoNetException(ex); } return next(chunk); }
protected final Object next() { try { int total = 0; while (total < chunk.length) { int count = input.read(chunk, total, chunk.length - total); if (count < 0) { if (total == 0) return null; byte[] partial = new byte[total]; System.arraycopy(chunk, 0, partial, 0, total); return next(partial); } total += count; } } catch (IOException ex) { throw new KryoNetException(ex); } return next(chunk); }
protected final Object next () { try { int total = 0; while (total < chunk.length) { int count = input.read(chunk, total, chunk.length - total); if (count < 0) { if (total == 0) return null; byte[] partial = new byte[total]; System.arraycopy(chunk, 0, partial, 0, total); return partial; } total += count; } } catch (IOException ex) { throw new KryoNetException(ex); } return next(chunk); }
private Object waitForResponse (byte responseID) { if (connection.getEndPoint().getUpdateThread() == Thread.currentThread()) throw new IllegalStateException("Cannot wait for an RMI response on the connection's update thread."); long endTime = System.currentTimeMillis() + timeoutMillis; while (true) { long remaining = endTime - System.currentTimeMillis(); InvokeMethodResult invokeMethodResult; synchronized (this) { invokeMethodResult = responseTable[responseID]; } if (invokeMethodResult != null) { lastResponseID = null; return invokeMethodResult.result; } else { if (remaining <= 0) throw new TimeoutException("Response timed out."); lock.lock(); try { responseCondition.await(remaining, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new KryoNetException(e); } finally { lock.unlock(); } } } }
private Object waitForResponse(byte responseID) { if (connection.getEndPoint().getUpdateThread() == Thread .currentThread()) throw new IllegalStateException( "Cannot wait for an RMI response on the connection's update thread."); long endTime = System.currentTimeMillis() + timeoutMillis; while (true) { long remaining = endTime - System.currentTimeMillis(); if (responseTable.containsKey(responseID)) { InvokeMethodResult invokeMethodResult = responseTable .get(responseID); responseTable.remove(responseID); lastResponseID = null; return invokeMethodResult.result; } else { if (remaining <= 0) throw new TimeoutException("Response timed out."); lock.lock(); try { responseCondition.await(remaining, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new KryoNetException(e); } finally { lock.unlock(); } } } }
@SuppressWarnings("unchecked") public void write(Kryo kryo, Output output, Object object) { Connection connection = (Connection) kryo.getContext().get( "connection"); int id = getRegisteredID(connection, object); if (id == Integer.MAX_VALUE) throw new KryoNetException( "Object not found in an ObjectSpace: " + object); output.writeInt(id, true); }
public void write (Kryo kryo, Output output, Object object) { Connection connection = (Connection)kryo.getContext().get("connection"); int id = getRegisteredID(connection, object); if (id == Integer.MAX_VALUE) throw new KryoNetException("Object not found in an ObjectSpace: " + object); output.writeInt(id, true); }