Guest User

Untitled

a guest
Nov 17th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. this.sendWSMessage(wsURL,this.buildGeoLocationMessage("27.1752868","78.040009"));
  2. private void sendWSMessage(String url,String message) throws IOException, WebSocketException, InterruptedException {
  3. JSONObject jsonObject = new JSONObject(message);
  4. final int messageId = jsonObject.getInt("id");
  5. if(ws==null){
  6. ws = new WebSocketFactory()
  7. .createSocket(url)
  8. .addListener(new WebSocketAdapter() {
  9. @Override
  10. public void onTextMessage(WebSocket ws, String message) {
  11. System.out.println(message);
  12. if(new JSONObject(message).getString("method").equals("Network.requestIntercepted ")){
  13. System.out.println("found");
  14. }
  15. if(new JSONObject(message).getInt("id")==messageId){
  16. synchronized (waitCoordinator) {
  17. waitCoordinator.notifyAll();
  18. }
  19. }
  20. }
  21. })
  22. .connect();
  23. }
  24. ws.sendText(message);
  25. synchronized (waitCoordinator) {
  26. waitCoordinator.wait(messageTimeoutInSecs*1000);
  27. }
  28. }
Add Comment
Please, Sign In to add comment