Class Helper

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

public final class Helper extends Object
  • Field Details

  • Constructor Details

    • Helper

      public Helper()
  • Method Details

    • getClientID

      public static String getClientID(cool.scx.http.ScxServerWebSocket serverWebSocket)
      从 ServerWebSocket 中获取 clientID
      Parameters:
      serverWebSocket - serverWebSocket
      Returns:
      clientID 没有返回 null
    • createConnectOptions

      public static cool.scx.http.uri.ScxURI createConnectOptions(String absoluteURI, String clientID)
      根据 uri 和 clientID 创建 ConnectOptions
      Parameters:
      absoluteURI - 后台连接的绝对路径
      clientID - 客户端 ID
      Returns:
      ConnectOptions
    • getDelayed

      public static long getDelayed(int times)
      根据次数获取延时时间 根据次数进行 2的 次方倍增 , 如 1, 2 ,4 ,8 ,16 等
      Parameters:
      times - 次数 (0 起始)
      Returns:
      延时时间 (毫秒)
    • 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)