Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.sendWSMessage(wsURL,this.buildGeoLocationMessage("27.1752868","78.040009"));
- private void sendWSMessage(String url,String message) throws IOException, WebSocketException, InterruptedException {
- JSONObject jsonObject = new JSONObject(message);
- final int messageId = jsonObject.getInt("id");
- if(ws==null){
- ws = new WebSocketFactory()
- .createSocket(url)
- .addListener(new WebSocketAdapter() {
- @Override
- public void onTextMessage(WebSocket ws, String message) {
- System.out.println(message);
- if(new JSONObject(message).getString("method").equals("Network.requestIntercepted ")){
- System.out.println("found");
- }
- if(new JSONObject(message).getInt("id")==messageId){
- synchronized (waitCoordinator) {
- waitCoordinator.notifyAll();
- }
- }
- }
- })
- .connect();
- }
- ws.sendText(message);
- synchronized (waitCoordinator) {
- waitCoordinator.wait(messageTimeoutInSecs*1000);
- }
- }
Add Comment
Please, Sign In to add comment