@Test public void publishReceivedCountsEmptyMessages() { assumeThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(0l)); listener.publishReceived(client, new PublishMessage("test", QoS.AT_LEAST_ONCE, (byte[]) null)); listener.publishReceived(client, new PublishMessage("test", QoS.AT_LEAST_ONCE, new byte[0])); assertThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(2l)); }
/** * Methode: refresh ---------------- * * @see Client#refresh(boolean) */ public void refresh(boolean animationInclusive) throws RemoteException { if (listener != null) { if (animationInclusive) { listener.boardConstellationChanged(server.getPieces()); } listener.statusChanged(); } }
/** * Send a the specified {@link ClientEvent} to all registered listeners * * @param ce Event to be sent. */ private void notifyListeners(ClientEvent ce) { assert (ce != null); Iterator i = listenerSet.iterator(); while (i.hasNext()) { Object o = i.next(); assert (o instanceof ClientListener); ClientListener cl = (ClientListener) o; cl.clientUpdate(this, ce); } }
@Override public void onError(WebSocket conn, Exception ex) { logger.debug("onError: "); if (mClientLister != null) { mClientLister.onError(conn, ex); } }
@Override public void onClose(WebSocket conn, int code, String reason, boolean remote) { logger.debug("onClose: "); if (mClientLister != null) { mClientLister.onClose(conn, code, reason, remote); } }
@Test public void publishReceivedCountsIncomingMessages() { assumeThat(metricRegistry.getMeters().get("test.incomingMessages").getCount(), is(0l)); listener.publishReceived(client, new PublishMessage("test", QoS.AT_LEAST_ONCE)); assertThat(metricRegistry.getMeters().get("test.incomingMessages").getCount(), is(1l)); }
@Override public void onReceive(Object msg) throws Exception { if (msg instanceof Connect) { InetSocketAddress address = ((Connect) msg).getAddress(); log.debug("connecting to " + address); ActorRef tcp = Tcp.get(getContext().system()).manager(); tcp.tell(TcpMessage.connect(address), getSelf()); } else if (msg instanceof CommandFailed) { log.error(msg.toString()); app.tell(new ConnectFailed((CommandFailed) msg), getSelf()); } else if (msg instanceof Connected) { log.info("connected"); ActorRef listener = getContext() .actorOf(ClientListener.props(config), nameGenerator.getName(ClientListener.class)); listener.tell(msg, getSender()); getContext().watch(listener); } else if (msg instanceof Terminated) { log.warning("connection closed"); app.tell(new ConnectionClosed(), getSelf()); } else { unhandled(msg); } }
@Override public void onMessage(WebSocket conn, String message) { logger.debug("onMessage: " + message); if (mClientLister != null) { mClientLister.onMessage(conn, message); } }
@Test public void publishReceivedCountsDuplicateMessages() { final PublishMessage message = new PublishMessage("test", QoS.EXACTLY_ONCE, "test"); assumeThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(0l)); listener.publishReceived(client, message); // assertThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(1l)); }
@Override public void onOpen(WebSocket conn, ClientHandshake handshake) { logger.debug("onOpen: " /*+ conn.getRemoteSocketAddress().getHostName().toString()*/); if (mClientLister != null) { mClientLister.onOpen(conn, handshake); } }
@Test public void publishReceivedCountsDiscardedMessages() throws BufferOutOfCapacityException, ProcessingDisabledException { final PublishMessage message = new PublishMessage("test", QoS.AT_LEAST_ONCE, ""); assumeThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(0l)); listener.publishReceived(client, message); assertThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(1l)); }
public void stopServer() { if (client != null && client.connected) { client.closeSocket(); } client = null; if (listener != null) { listener.closeSocket(); } listener = null; }
public Client(String host, int portNumber) { keyboard = new Scanner(System.in); while (!openConnection(host, portNumber)) {} listener = new ClientListener(); System.out.println("Client(): Starting listener = : " + listener); listener.start(); listenToUserRequests(); closeAll(); }
@Test @SuppressWarnings("unchecked") public void connectedSubscribesToTopics() throws MisfireException { final MqttClient client = mock(MqttClient.class); listener.connected(client, ConnectReturnCode.ACCEPTED); final ArgumentCaptor<List> argumentCaptor = ArgumentCaptor.forClass(List.class); verify(client).subscribe((List<Subscription>) argumentCaptor.capture()); assertThat(argumentCaptor.getValue().size(), is(1)); final List<Subscription> subscriptions = argumentCaptor.getValue(); assertThat(subscriptions.get(0).getTopic(), equalTo("test")); assertThat(subscriptions.get(0).getQos(), equalTo(QoS.AT_LEAST_ONCE)); }
public void onDestroy() { // savePreferences("myPref"); // savePreferences("preferences"); if (!isRecording) { Log.i(TAG, "in onDestroy"); if (conn != null) { try { conn.stop(); } catch (Exception e) { Log.i(TAG, "Error in socket close: " + e.getMessage()); } } stop = true; super.onDestroy(); } }
public void run() { DefaultSmppClient client = new DefaultSmppClient(); SmppSession session = null; try { if (testNumber == 1) { session = client.bind( ConfigInit.getSmppSessionConfiguration(1, false), new DefaultSmppClientHandler()); logger.info("stopping server 1"); serverArray[1].stop(); logger.info("stopping server 2"); serverArray[2].stop(); sleep(5000); session.submit(ConfigInit.getSubmitSm(), 12000); sleep(1000); session.unbind(5000); serverArray[1].start(); serverArray[2].start(); } if (testNumber == 2) { session = client.bind( ConfigInit.getSmppSessionConfiguration(1, false), new DefaultSmppClientHandler()); serverArray[2].stop(); serverArray[2].start(); sleep(2000); for (int j = 0; j < 6; j++) { session.submit(ConfigInit.getSubmitSm(), 12000); } sleep(1000); session.unbind(5000); } } catch (Exception e) { logger.error("", e); } if (session != null) { logger.info("Cleaning up session..."); session.destroy(); } logger.info("Shutting down client bootstrap and executors..."); client.destroy(); listener.clientCompleted(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ipfield = (EditText) findViewById(R.id.ipfield); portfield = (EditText) findViewById(R.id.portfield); captureButton = (Button) findViewById(R.id.button_capture); captureButton.setOnClickListener(this); // onStartCommand(); SurfaceView cameraView = (SurfaceView) findViewById(R.id.camera_preview); holder = cameraView.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // constructorVideo(); }
public void run() { DefaultSmppClient client = new DefaultSmppClient(); SmppSession session = null; try { clientHandlerArray[i] = new DefaultSmppClientHandler(); session = client.bind(ConfigInit.getSmppSessionConfiguration(i, false), clientHandlerArray[i]); for (int j = 0; j < smsNumber; j++) { session.submit(ConfigInit.getSubmitSm(), 12000); } sleep(3000); session.unbind(5000); } catch (Exception e) { logger.error("", e); } if (session != null) { logger.info("Cleaning up session..."); session.destroy(); } logger.info("Shutting down client bootstrap and executors..."); client.destroy(); listener.clientCompleted(); }
/** * Methode: recieveRadioMessage ---------------------------- * * @see Client#recieveRadioMessage(String) */ public void recieveRadioMessage(String msg) throws RemoteException { if (listener != null) { listener.showRadioMessage(msg); } }
@Override public void processEvent(NetListener listener) { ((ClientListener) listener).clientDisconnected(client); }
@Test public void testDisconnected() { listener.disconnected(client, null, false); }
@Override protected void onPause() { super.onPause(); releaseMediaRecorder(); // if you are using MediaRecorder, release it first releaseCamera(); // release the camera immediately on pause event }
/** * Methode: recieveErrorMessage ---------------------------- * * @see Client#recieveErrorMessage(String) */ public void recieveErrorMessage(String msg) throws RemoteException { listener.showErrorMessage(msg); }