151 T attachment, |
151 T attachment, |
152 BiConsumer<? super T, ? super Throwable> action) { |
152 BiConsumer<? super T, ? super Throwable> action) { |
153 long id = 0; |
153 long id = 0; |
154 if (debug.isLoggable(Level.DEBUG)) { |
154 if (debug.isLoggable(Level.DEBUG)) { |
155 id = counter.incrementAndGet(); |
155 id = counter.incrementAndGet(); |
156 debug.log(Level.DEBUG, "enter send binary %s message.remaining()=%s last=%s%n", |
156 debug.log(Level.DEBUG, "enter send binary %s message.remaining()=%s last=%s", |
157 id, message.remaining(), isLast); |
157 id, message.remaining(), isLast); |
158 } |
158 } |
159 MinimalFuture<T> f = new MinimalFuture<>(); |
159 MinimalFuture<T> f = new MinimalFuture<>(); |
160 try { |
160 try { |
161 queue.addBinary(message, isLast, attachment, action, f); |
161 queue.addBinary(message, isLast, attachment, action, f); |
162 sendScheduler.runOrSchedule(); |
162 sendScheduler.runOrSchedule(); |
163 } catch (IOException e) { |
163 } catch (IOException e) { |
164 f.completeExceptionally(e); |
164 f.completeExceptionally(e); |
165 } |
165 } |
166 debug.log(Level.DEBUG, "exit send binary %s returned %s%n", id, f); |
166 debug.log(Level.DEBUG, "exit send binary %s returned %s", id, f); |
167 return f; |
167 return f; |
168 } |
168 } |
169 |
169 |
170 @Override |
170 @Override |
171 public <T> CompletableFuture<T> sendPing(ByteBuffer message, |
171 public <T> CompletableFuture<T> sendPing(ByteBuffer message, |
172 T attachment, |
172 T attachment, |
173 BiConsumer<? super T, ? super Throwable> action) { |
173 BiConsumer<? super T, ? super Throwable> action) { |
174 long id = 0; |
174 long id = 0; |
175 if (debug.isLoggable(Level.DEBUG)) { |
175 if (debug.isLoggable(Level.DEBUG)) { |
176 id = counter.incrementAndGet(); |
176 id = counter.incrementAndGet(); |
177 debug.log(Level.DEBUG, "enter send ping %s message.remaining()=%s%n", |
177 debug.log(Level.DEBUG, "enter send ping %s message.remaining()=%s", |
178 id, message.remaining()); |
178 id, message.remaining()); |
179 } |
179 } |
180 MinimalFuture<T> f = new MinimalFuture<>(); |
180 MinimalFuture<T> f = new MinimalFuture<>(); |
181 try { |
181 try { |
182 queue.addPing(message, attachment, action, f); |
182 queue.addPing(message, attachment, action, f); |
183 sendScheduler.runOrSchedule(); |
183 sendScheduler.runOrSchedule(); |
184 } catch (IOException e) { |
184 } catch (IOException e) { |
185 f.completeExceptionally(e); |
185 f.completeExceptionally(e); |
186 } |
186 } |
187 debug.log(Level.DEBUG, "exit send ping %s returned %s%n", id, f); |
187 debug.log(Level.DEBUG, "exit send ping %s returned %s", id, f); |
188 return f; |
188 return f; |
189 } |
189 } |
190 |
190 |
191 @Override |
191 @Override |
192 public <T> CompletableFuture<T> sendPong(ByteBuffer message, |
192 public <T> CompletableFuture<T> sendPong(ByteBuffer message, |
193 T attachment, |
193 T attachment, |
194 BiConsumer<? super T, ? super Throwable> action) { |
194 BiConsumer<? super T, ? super Throwable> action) { |
195 long id = 0; |
195 long id = 0; |
196 if (debug.isLoggable(Level.DEBUG)) { |
196 if (debug.isLoggable(Level.DEBUG)) { |
197 id = counter.incrementAndGet(); |
197 id = counter.incrementAndGet(); |
198 debug.log(Level.DEBUG, "enter send pong %s message.remaining()=%s%n", |
198 debug.log(Level.DEBUG, "enter send pong %s message.remaining()=%s", |
199 id, message.remaining()); |
199 id, message.remaining()); |
200 } |
200 } |
201 MinimalFuture<T> f = new MinimalFuture<>(); |
201 MinimalFuture<T> f = new MinimalFuture<>(); |
202 try { |
202 try { |
203 queue.addPong(message, attachment, action, f); |
203 queue.addPong(message, attachment, action, f); |
204 sendScheduler.runOrSchedule(); |
204 sendScheduler.runOrSchedule(); |
205 } catch (IOException e) { |
205 } catch (IOException e) { |
206 f.completeExceptionally(e); |
206 f.completeExceptionally(e); |
207 } |
207 } |
208 debug.log(Level.DEBUG, "exit send pong %s returned %s%n", id, f); |
208 debug.log(Level.DEBUG, "exit send pong %s returned %s", id, f); |
209 return f; |
209 return f; |
210 } |
210 } |
211 |
211 |
212 @Override |
212 @Override |
213 public <T> CompletableFuture<T> sendPong(Supplier<? extends ByteBuffer> message, |
213 public <T> CompletableFuture<T> sendPong(Supplier<? extends ByteBuffer> message, |
214 T attachment, |
214 T attachment, |
215 BiConsumer<? super T, ? super Throwable> action) { |
215 BiConsumer<? super T, ? super Throwable> action) { |
216 long id = 0; |
216 long id = 0; |
217 if (debug.isLoggable(Level.DEBUG)) { |
217 if (debug.isLoggable(Level.DEBUG)) { |
218 id = counter.incrementAndGet(); |
218 id = counter.incrementAndGet(); |
219 debug.log(Level.DEBUG, "enter send pong %s supplier=%s%n", |
219 debug.log(Level.DEBUG, "enter send pong %s supplier=%s", |
220 id, message); |
220 id, message); |
221 } |
221 } |
222 MinimalFuture<T> f = new MinimalFuture<>(); |
222 MinimalFuture<T> f = new MinimalFuture<>(); |
223 try { |
223 try { |
224 queue.addPong(message, attachment, action, f); |
224 queue.addPong(message, attachment, action, f); |
225 sendScheduler.runOrSchedule(); |
225 sendScheduler.runOrSchedule(); |
226 } catch (IOException e) { |
226 } catch (IOException e) { |
227 f.completeExceptionally(e); |
227 f.completeExceptionally(e); |
228 } |
228 } |
229 debug.log(Level.DEBUG, "exit send pong %s returned %s%n", id, f); |
229 debug.log(Level.DEBUG, "exit send pong %s returned %s", id, f); |
230 return f; |
230 return f; |
231 } |
231 } |
232 |
232 |
233 @Override |
233 @Override |
234 public <T> CompletableFuture<T> sendClose(int statusCode, |
234 public <T> CompletableFuture<T> sendClose(int statusCode, |