Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#/io/vertx/ext/web/handler/sockjs/BridgeEventHandler
$class=io.vertx.reactivex.ext.web.handler.sockjs.DefaultBridgeEventHandler
$class=io.vertx.reactivex.ext.web.handler.sockjs.BridgeEventHandler

addressAllowedToRegister=
addressAllowedToRegisterRegex=
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import in.erail.common.FramworkConstants;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonObject;
import java.util.List;

/**
*
* @author vinay
*/
public class DefaultBridgeEventHandler implements Handler<BridgeEvent> {
public class BridgeEventHandler implements Handler<BridgeEvent> {

private List<String> mAddressAllowedToRegister;
private List<String> mAddressAllowedToRegisterRegex;

@Override
public void handle(BridgeEvent pEvent) {
Expand Down Expand Up @@ -52,15 +56,52 @@ public void handle(BridgeEvent pEvent) {

}

public void handlePublish(String pAddress, BridgeEvent pEvent) {
pEvent.complete(true);
public void handleRegister(String pAddress, BridgeEvent pEvent) {
if (mAddressAllowedToRegister.isEmpty() && mAddressAllowedToRegisterRegex.isEmpty()) {
pEvent.complete(true);
return;
}

if (!(matchAddress(pAddress) || matchAddressRegex(pAddress))) {
pEvent.fail("Can't subscribe to topic : " + pAddress);
} else {
pEvent.complete(true);
}
}

public void handleRecieve(String pAddress, BridgeEvent pEvent) {
private boolean matchAddress(String pAddress) {
return mAddressAllowedToRegister
.stream()
.anyMatch((allowedAddress) -> (pAddress.equals(allowedAddress)));
}

private boolean matchAddressRegex(String pAddress) {
return mAddressAllowedToRegisterRegex
.stream()
.anyMatch((allowedAddress) -> (pAddress.matches(allowedAddress)));
}

public List<String> getAddressAllowedToRegister() {
return mAddressAllowedToRegister;
}

public void setAddressAllowedToRegister(List<String> pAddressAllowedToRegister) {
this.mAddressAllowedToRegister = pAddressAllowedToRegister;
}

public List<String> getAddressAllowedToRegisterRegex() {
return mAddressAllowedToRegisterRegex;
}

public void setAddressAllowedToRegisterRegex(List<String> pAddressAllowedToRegisterRegex) {
this.mAddressAllowedToRegisterRegex = pAddressAllowedToRegisterRegex;
}

public void handlePublish(String pAddress, BridgeEvent pEvent) {
pEvent.complete(true);
}

public void handleRegister(String pAddress, BridgeEvent pEvent) {
public void handleRecieve(String pAddress, BridgeEvent pEvent) {
pEvent.complete(true);
}

Expand Down