Skip to content

Commit

Permalink
新增: 优化SendEvent和SendMsg,代码格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhailin committed Nov 7, 2020
1 parent 7f24227 commit ac4e86c
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
@EslEventName(EventNames.HEARTBEAT)
@Component
public class HeartbeatEslEventHandler implements EslEventHandler {
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void handle(String addr, EslEvent event) {
log.info("HeartbeatEslEventHandler handle addr[{}] EslEvent[{}].", addr, event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public void onOpened(ServerOption serverOption) {
log.info("onOpened serverOption : {}", serverOption);
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void onClosed(ServerOption serverOption) {
log.info("onClosed serverOption : {}", serverOption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
package link.thingscloud.freeswitch.esl.spring.boot.starter.example.controller;

import link.thingscloud.freeswitch.esl.InboundClient;
import link.thingscloud.freeswitch.esl.inbound.option.InboundClientOption;
import link.thingscloud.freeswitch.esl.inbound.option.ServerOption;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* <p>DemoController class.</p>
*
Expand Down Expand Up @@ -80,6 +77,7 @@ public void removeServer1() {
ServerOption serverOption = inboundClient.option().serverOptions().get(0);
inboundClient.option().removeServerOption(serverOption);
}

/**
* <p>serverOptions.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
* @version $Id: $Id
*/
public class DefaultEslEventHandler extends AbstractEslEventHandler {
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void handle(String addr, EslEvent event) {
log.warn("Default esl event handler handle addr[{}], event[{}]", addr, EslHelper.formatEslEvent(event));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
@Component
public class IEslEventListenerTemplate implements IEslEventListener, InitializingBean, ApplicationContextAware {

@Autowired
@Autowired
private InboundClient inboundClient;
private ApplicationContext applicationContext;
private EslEventHandler defaultEventHandler = new DefaultEslEventHandler();
Expand All @@ -62,7 +62,9 @@ public void eventReceived(String addr, EslEvent event) {
handleEslEvent(addr, event);
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void backgroundJobResultReceived(String addr, EslEvent event) {
handleEslEvent(addr, event);
Expand All @@ -79,7 +81,9 @@ private void handleEslEvent(String addr, EslEvent event) {
}


/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void afterPropertiesSet() {
log.info("IEslEventListener init ...");
Expand Down Expand Up @@ -110,7 +114,9 @@ public void afterPropertiesSet() {
inboundClient.option().addListener(this);
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public void onOpened(ServerOption serverOption) {
log.info("onOpened serverOption : {}", serverOption.host() + ":" + serverOption.port());
}

/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public void onClosed(ServerOption serverOption) {
log.info("onClosed serverOption : {}", serverOption.host() + ":" + serverOption.port());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static InboundClient getInstance() {
* @param timeoutSeconds timeout seconds arguments
* @return an {@link link.thingscloud.freeswitch.esl.transport.message.EslMessage} containing command results
* @throws link.thingscloud.freeswitch.esl.exception.InboundTimeoutExcetion ite execute command timeout
* @throws link.thingscloud.freeswitch.esl.exception.InboundTimeoutExcetion if any.
*/
EslMessage sendSyncApiCommand(String addr, String command, String arg, long timeoutSeconds) throws InboundTimeoutExcetion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.handler.timeout.ReadTimeoutHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class SendEvent {
* Constructor for use with outbound socket client only. This client mode does not need a call
* UUID for context.
*
* @param name part of line
* @param name part of line
*/
public SendEvent(String name) {
msgLines.add("sendevent " + name);
Expand All @@ -49,9 +49,11 @@ public SendEvent(String name) {
*
* @param name part of line
* @param value part of line
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendEvent} object.
*/
public void addLine(String name, String value) {
public SendEvent addLine(String name, String value) {
msgLines.add(name + ": " + value);
return this;
}

/**
Expand Down Expand Up @@ -92,5 +94,4 @@ public String toString() {
return sb.toString();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ public SendMsg(String uuid) {
* </pre>
*
* @param command the string command [ execute | hangup ]
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendMsg} object.
*/
public void addCallCommand(String command) {
public SendMsg addCallCommand(String command) {
msgLines.add("call-command: " + command);
return this;
}

/**
Expand All @@ -69,9 +71,11 @@ public void addCallCommand(String command) {
* </pre>
*
* @param appName the string app name to execute
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendMsg} object.
*/
public void addExecuteAppName(String appName) {
public SendMsg addExecuteAppName(String appName) {
msgLines.add("execute-app-name: " + appName);
return this;
}

/**
Expand All @@ -81,9 +85,11 @@ public void addExecuteAppName(String appName) {
* </pre>
*
* @param arg the string arg
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendMsg} object.
*/
public void addExecuteAppArg(String arg) {
public SendMsg addExecuteAppArg(String arg) {
msgLines.add("execute-app-arg: " + arg);
return this;
}

/**
Expand All @@ -93,9 +99,11 @@ public void addExecuteAppArg(String arg) {
* </pre>
*
* @param count the int number of times to loop
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendMsg} object.
*/
public void addLoops(int count) {
public SendMsg addLoops(int count) {
msgLines.add("loops: " + count);
return this;
}

/**
Expand All @@ -105,9 +113,11 @@ public void addLoops(int count) {
* </pre>
*
* @param cause the string cause
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendMsg} object.
*/
public void addHangupCause(String cause) {
public SendMsg addHangupCause(String cause) {
msgLines.add("hangup-cause: " + cause);
return this;
}

/**
Expand All @@ -117,19 +127,24 @@ public void addHangupCause(String cause) {
* </pre>
*
* @param value the string value part of the line
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendMsg} object.
*/
public void addNomediaUuid(String value) {
public SendMsg addNomediaUuid(String value) {
msgLines.add("nomedia-uuid: " + value);
return this;
}

/**
* Adds the following line to the message:
* <pre>
* event-lock: true
* </pre>
*
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendMsg} object.
*/
public void addEventLock() {
public SendMsg addEventLock() {
msgLines.add("event-lock: true");
return this;
}

/**
Expand All @@ -141,9 +156,11 @@ public void addEventLock() {
*
* @param name part of line
* @param value part of line
* @return a {@link link.thingscloud.freeswitch.esl.transport.SendMsg} object.
*/
public void addGenericLine(String name, String value) {
public SendMsg addGenericLine(String name, String value) {
msgLines.add(name + ": " + value);
return this;
}

/**
Expand Down

0 comments on commit ac4e86c

Please sign in to comment.