当前位置: 首页 > 工具软件 > ioserver > 使用案例 >

java作为客户端连接socket.io-server

贾成天
2023-12-01

1、pom文件

        <dependency>
            <groupId>io.socket</groupId>
            <artifactId>socket.io-client</artifactId>
            <version>1.0.0</version>
        </dependency>

2、连接websocket服务端

package sample.cluster.simple;

import akka.actor.typed.ActorSystem;
import akka.actor.typed.Behavior;
import akka.actor.typed.javadsl.Behaviors;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;
import org.json.JSONException;
import org.json.JSONObject;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class IMApp {

    public static void main(String[] args) throws URISyntaxException {
        IO.Options options = new IO.Options();
    
 类似资料: