zhouhailin / freeswitch-externals

FreeSWITCH externals projects
https://zhouhailin.github.io/freeswitch-externals/
Apache License 2.0
163 stars 83 forks source link

疑似event命令重复拼接 #8

Closed Lswks closed 4 years ago

Lswks commented 4 years ago

    /** {@inheritDoc} */
    @Override
    public void handleAuthRequest(String addr, InboundChannelHandler inboundChannelHandler) {
        log.info("Auth requested[{}], sending [auth {}]", addr, "*****");
        for (ServerOption serverOption : option().serverOptions()) {
            String password = serverOption.password();
            if (password == null) {
                password = option().defaultPassword();
            }
            if (StringUtils.equals(addr, serverOption.addr())) {
                EslMessage response = inboundChannelHandler.sendSyncSingleLineCommand("auth " + password);
                log.debug("Auth response [{}]", response);
                if (response.getContentType().equals(EslHeaders.Value.COMMAND_REPLY)) {
                    CommandResponse reply = new CommandResponse("auth " + password, response);
                    serverOption.state(ConnectState.AUTHED);
                    log.info("Auth response success={}, message=[{}]", reply.isOk(), reply.getReplyText());
                    if (!option().events().isEmpty()) {
                        StringBuilder sb = new StringBuilder();
                        sb.append("event plain ");
                        for (String event : option().events()) {
                            sb.append(event).append(" ");
                        }
                        setEventSubscriptions(addr, "plain", sb.toString());
                    }
                } else {
                    serverOption.state(ConnectState.AUTHED_FAILED);
                    log.error("Bad auth response message [{}]", response);
                    throw new IllegalStateException("Incorrect auth response");
                }
            }
        }
    }

setEventSubscriptions(addr, "plain", sb.toString()); 这句是不是有个bug呢,因为setEventSubscriptions里面的逻辑是'event ' + 'plain ' + sb.toString(), 这时会造成重复拼接,以all为例,最后出来一个event plain event plain all 。 仅看了代码,没有调试~

zhouhailin commented 4 years ago

非常感谢,的确存在重复拼接的问题。目前已调整,后期如遇到问题,可以直接提ISSUE和PR,谢谢。