Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

read wss endpoint java

package testapp;

import java.net.URI;
import java.net.URISyntaxException;

public class TestApp {

    public static void main(String[] args) {
        try {
            // open websocket
            final WebsocketClientEndpoint clientEndPoint = new WebsocketClientEndpoint(new URI("wss://real.okcoin.cn:10440/websocket/okcoinapi"));

            // add listener
            clientEndPoint.addMessageHandler(new WebsocketClientEndpoint.MessageHandler() {
                public void handleMessage(String message) {
                    System.out.println(message);
                }
            });

            // send message to websocket
            clientEndPoint.sendMessage("{'event':'addChannel','channel':'ok_btccny_ticker'}");

            // wait 5 seconds for messages from websocket
            Thread.sleep(5000);

        } catch (InterruptedException ex) {
            System.err.println("InterruptedException exception: " + ex.getMessage());
        } catch (URISyntaxException ex) {
            System.err.println("URISyntaxException exception: " + ex.getMessage());
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to run java files 
Java :: hashtable java 
Java :: converting char array to string 
Java :: chenge font android studio 
Java :: spring boot dockerfile 
Java :: java stream and filter 
Java :: spring boot onetomany relationsion 
Java :: asscending linkedlist remove duplicates valuesjava 
Java :: java leap years 
Java :: loop through number java 
Java :: java arraylist add 
Java :: declare bufferedreader java 
Java :: how to change custom font to bold italic in java 
Java :: delet file from path android 
Java :: do statement java 
Java :: where is java in ubuntu 
Java :: create a hashmap 
Java :: how to convert line into string java 
Java :: how to name loops in java 
Java :: get executable path java 
Java :: calling this in constructor java 
Java :: what are abstract methods in java 
Java :: java print method 
Java :: android navigation drawer open activity 
Java :: spring xml configuration 
Java :: input using stringbuffer 
Java :: a?che les paramètres de la ligne de commande triés par ordre lexicographique en java 
Java :: fragment view in XML android 
Java :: localdate to string java 
Java :: java stream inner join two lists 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =