程序包 cool.scx.socket

类 Helper

java.lang.Object
cool.scx.socket.Helper

public final class Helper extends Object
  • 字段详细资料

  • 构造器详细资料

    • Helper

      public Helper()
  • 方法详细资料

    • setTimeout

      public static io.netty.util.Timeout setTimeout(Runnable task, long delay)
      创建 Timeout 使用 Netty 时间轮 可能不准确但占用资源少
      参数:
      task - 任务
      delay - 延时
      返回:
      Timeout
    • getClientID

      public static String getClientID(io.vertx.core.http.ServerWebSocket serverWebSocket)
      从 ServerWebSocket 中获取 clientID
      参数:
      serverWebSocket - serverWebSocket
      返回:
      clientID 没有返回 null
    • createConnectOptions

      public static io.vertx.core.http.WebSocketConnectOptions createConnectOptions(String absoluteURI, String clientID)
      根据 uri 和 clientID 创建 ConnectOptions
      参数:
      absoluteURI - 后台连接的绝对路径
      clientID - 客户端 ID
      返回:
      ConnectOptions
    • getDelayed

      public static long getDelayed(int times)
      根据次数获取延时时间 根据次数进行 2的 次方倍增 , 如 1, 2 ,4 ,8 ,16 等
      参数:
      times - 次数 (0 起始)
      返回:
      延时时间 (毫秒)
    • toJson

      public static String toJson(Object data)
    • fromJson

      public static <T> T fromJson(String json, Class<T> tClass)
    • fromJson

      public static <T> T fromJson(String json, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)