I'm trying to get some data from a trading platform (https://www.binary.com). The code samples for getting data from them is provided at the developers' site (https://developers.binary.com/demos/).
Since I was using android studio, I opted for java, copied the code, created a new class, and pasted the code there.
Here's my code:
package com.example.smijes.myapplication;
import java.net.URI;
import java.io.IOException;
import java.lang.InterruptedException;
import javax.websocket.*;
@ClientEndpoint
public class WSClient {
@OnOpen
public void onOpen(Session session) throws java.io.IOException {
session.getBasicRemote().sendText("{\"ticks\": \"R_100\"}");
}
@OnMessage
public void onMessage(String message) {
System.out.println("ticks update: " + message);
}
public static void main(String[] args)
throws IOException, DeploymentException, InterruptedException {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
URI apiUri = URI.create("wss://ws.binaryws.com/websockets/v3?app_id=1089");
Session session = container.connectToServer(WSClient.class, apiUri);
Thread.sleep(10000);
}
}
I noticed some errors, did some research then added a dependency to my app level build.gradle file:
implementation "org.java-websocket:Java-WebSocket:1.3.8
After synchronizing gradle, I noticed the error persisted.
Here is a screenshot to show the errors:
I think the entire problem is from the import javax.websocket.*;
line of code. I also think the dependency I added doesn't correspond. Can the dependency I added be for java.websocket
rather than javax.websocket
?
I'm using Android Studio 3.1.3.