Class AbstractClientCommandStrategy

java.lang.Object
io.github.lunasaw.gbproxy.client.transmit.cmd.strategy.AbstractClientCommandStrategy
All Implemented Interfaces:
ClientCommandStrategy
Direct Known Subclasses:
AckCommandStrategy, ByeCommandStrategy, InfoCommandStrategy, InviteCommandStrategy, MessageCommandStrategy, NotifyCommandStrategy, RegisterCommandStrategy, SubscribeCommandStrategy

public abstract class AbstractClientCommandStrategy extends Object implements ClientCommandStrategy
抽象客户端命令策略基类 提供通用的命令执行逻辑和工具方法
Author:
luna
  • Constructor Details

    • AbstractClientCommandStrategy

      public AbstractClientCommandStrategy()
  • Method Details

    • execute

      public String execute(FromDevice fromDevice, ToDevice toDevice, Object... params)
      Description copied from interface: ClientCommandStrategy
      执行命令
      Specified by:
      execute in interface ClientCommandStrategy
      Parameters:
      fromDevice - 发送设备
      toDevice - 接收设备
      params - 命令参数
      Returns:
      callId
    • execute

      public String execute(FromDevice fromDevice, ToDevice toDevice, Event errorEvent, Event okEvent, Object... params)
      Description copied from interface: ClientCommandStrategy
      执行命令(带事件)
      Specified by:
      execute in interface ClientCommandStrategy
      Parameters:
      fromDevice - 发送设备
      toDevice - 接收设备
      errorEvent - 错误事件
      okEvent - 成功事件
      params - 命令参数
      Returns:
      callId
    • validateParams

      protected void validateParams(FromDevice fromDevice, ToDevice toDevice, Object... params)
      参数校验
      Parameters:
      fromDevice - 发送设备
      toDevice - 接收设备
      params - 参数
    • buildCommandContent

      protected String buildCommandContent(FromDevice fromDevice, ToDevice toDevice, Object... params)
      构建命令内容
      Parameters:
      fromDevice - 发送设备
      toDevice - 接收设备
      params - 参数
      Returns:
      命令内容
    • sendCommand

      protected String sendCommand(FromDevice fromDevice, ToDevice toDevice, String content, Event errorEvent, Event okEvent)
      发送命令
      Parameters:
      fromDevice - 发送设备
      toDevice - 接收设备
      content - 命令内容
      errorEvent - 错误事件
      okEvent - 成功事件
      Returns:
      callId
    • generateSn

      protected String generateSn()
      生成随机序列号
      Returns:
      序列号
    • getDeviceId

      protected String getDeviceId(FromDevice fromDevice)
      获取设备ID
      Parameters:
      fromDevice - 发送设备
      Returns:
      设备ID