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
@@ -0,0 +1,31 @@
/*
* Copyright 2014-2020 [fisco-dev]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

package org.fisco.bcos.sdk.eventsub;

import org.fisco.bcos.sdk.channel.Channel;
import org.fisco.bcos.sdk.service.GroupManagerService;
import org.fisco.bcos.sdk.service.GroupManagerServiceImpl;
import org.junit.Test;

public class SubscribeTest {

@Test
public void TestInitEventSubModule(){
// Init event subscribe module.


}
}
30 changes: 22 additions & 8 deletions src/main/java/org/fisco/bcos/sdk/amop/Amop.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.List;
import org.fisco.bcos.sdk.channel.Channel;
import org.fisco.bcos.sdk.config.ConfigOption;
import org.fisco.bcos.sdk.crypto.keystore.KeyManager;

/**
* AMOP module interface.
Expand All @@ -28,36 +30,40 @@ public interface Amop {
* Create a Amop object.
*
* @param channel
* @param configFile
* @param config
* @return Amop instance
*/
static Amop build(Channel channel, String configFile) {
static Amop build(Channel channel, ConfigOption config) {
return null;
}

/**
* Subscribe a normal topic.
*
* @param topicName
* @param callback callback is called when receive a msg relate to this topic
*/
void subscribeTopic(String topicName);
void subscribeTopic(String topicName, AmopCallback callback);

/**
* Subscribe a topic which need verify.
* Subscribe a private topic which need verify.
*
* @param topicName
* @param privateKey
* @param privateKeyManager the private key you used to prove your identity.
* @param callback callback is called when receive a msg relate to this topic
*/
void subscribeNeedVerifyTopics(String topicName, String privateKey);
void subscribePrivateTopics(
String topicName, KeyManager privateKeyManager, AmopCallback callback);

/**
* Config a topic which is need verification, after that user can send message to verified
* subscriber.
*
* @param topicName
* @param publicKeys
* @param publicKeyManagers the public keys of the target organizations that you want to
* communicate with
*/
void addNeedVerifyTopics(String topicName, List<String> publicKeys);
void setupPrivateTopic(String topicName, List<KeyManager> publicKeyManagers);

/**
* Unsubscribe a topic.
Expand All @@ -66,6 +72,14 @@ static Amop build(Channel channel, String configFile) {
*/
void unsubscribeTopic(String topicName);

/**
* Send amop msg
*
* @param msg
* @param callback
*/
void sendAmopMsg(AmopMsg msg, AmopCallback callback);

/**
* Get all subscribe topics.
*
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/amop/AmopCallback.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2014-2020 [fisco-dev]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

package org.fisco.bcos.sdk.amop;

public abstract class AmopCallback {
public abstract void onSubscribedTopicMsg();
}
66 changes: 66 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/amop/AmopImp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2014-2020 [fisco-dev]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

package org.fisco.bcos.sdk.amop;

import java.util.List;
import org.fisco.bcos.sdk.amop.exception.AmopException;
import org.fisco.bcos.sdk.channel.Channel;
import org.fisco.bcos.sdk.config.ConfigOption;
import org.fisco.bcos.sdk.crypto.keystore.KeyManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Amop implement
*
* @author Maggie
*/
public class AmopImp implements Amop {
private static Logger logger = LoggerFactory.getLogger(AmopImp.class);
private Channel ch;

public AmopImp(Channel channel, ConfigOption config) throws AmopException {
this.ch = channel;
// todo load topics ConfigOption
}

@Override
public void subscribeTopic(String topicName, AmopCallback callback) {}

@Override
public void subscribePrivateTopics(
String topicName, KeyManager privateKeyManager, AmopCallback callback) {}

@Override
public void setupPrivateTopic(String topicName, List<KeyManager> publicKeyManagers) {}

@Override
public void unsubscribeTopic(String topicName) {}

@Override
public void sendAmopMsg(AmopMsg msg, AmopCallback callback) {}

@Override
public List<String> getSubTopics() {
return null;
}

@Override
public void start() {}

@Override
public void stop() {}
}
18 changes: 18 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/amop/AmopMsg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2014-2020 [fisco-dev]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

package org.fisco.bcos.sdk.amop;

public class AmopMsg {}
30 changes: 30 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/amop/exception/AmopException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2014-2020 [fisco-dev]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

package org.fisco.bcos.sdk.amop.exception;

public class AmopException extends Exception {
public AmopException(String message) {
super(message);
}

public AmopException(Throwable cause) {
super(cause);
}

public AmopException(String message, Throwable cause) {
super(message, cause);
}
}
32 changes: 32 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/amop/topic/AmopMsgHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2014-2020 [fisco-dev]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

package org.fisco.bcos.sdk.amop.topic;

import io.netty.channel.ChannelHandlerContext;
import org.fisco.bcos.sdk.model.Message;
import org.fisco.bcos.sdk.network.MsgHandler;

public class AmopMsgHandler implements MsgHandler {

@Override
public void onConnect(ChannelHandlerContext ctx) {}

@Override
public void onMessage(ChannelHandlerContext ctx, Message msg) {}

@Override
public void onDisconnect(ChannelHandlerContext ctx) {}
}
25 changes: 25 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/amop/topic/AmopTopic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2014-2020 [fisco-dev]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

package org.fisco.bcos.sdk.amop.topic;

import org.fisco.bcos.sdk.amop.AmopCallback;

public class AmopTopic {
private String topicName;
private String type;
private String topicString;
private AmopCallback callback;
}
43 changes: 43 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/amop/topic/TopicManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2014-2020 [fisco-dev]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
*/

package org.fisco.bcos.sdk.amop.topic;

import java.security.KeyStore;
import java.util.List;
import java.util.Map;
import org.fisco.bcos.sdk.amop.AmopCallback;

public class TopicManager {
Map<String, AmopCallback> seq2Callback;
Map<String, KeyStore> topic2PrivateKey;
Map<String, List<KeyStore>> topic2PublicKey;

public void addTopic(String topicName, AmopCallback callback) {
return;
}

public void addPrivateTopic(String topicName, KeyStore privateKeyStore, AmopCallback callback) {
return;
}

public void removeTopic(String topicName) {
return;
}

public AmopCallback getCallback(String seq) {
return seq2Callback.get(seq);
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/fisco/bcos/sdk/client/ClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.fisco.bcos.sdk.client.exceptions.ClientException;
import org.fisco.bcos.sdk.client.protocol.request.GenerateGroupParam;
import org.fisco.bcos.sdk.client.protocol.request.JsonRpcMethods;
import org.fisco.bcos.sdk.client.protocol.request.JsonRpcRequest;
import org.fisco.bcos.sdk.client.protocol.request.Transaction;
import org.fisco.bcos.sdk.client.protocol.response.BcosBlock;
import org.fisco.bcos.sdk.client.protocol.response.BcosBlockHeader;
Expand Down Expand Up @@ -54,7 +55,6 @@
import org.fisco.bcos.sdk.client.protocol.response.TotalTransactionCount;
import org.fisco.bcos.sdk.client.protocol.response.TransactionReceiptWithProof;
import org.fisco.bcos.sdk.client.protocol.response.TransactionWithProof;
import org.fisco.bcos.sdk.model.JsonRpcRequest;
import org.fisco.bcos.sdk.service.GroupManagerService;
import org.fisco.bcos.sdk.utils.Numeric;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.fisco.bcos.sdk.channel.ResponseCallback;
import org.fisco.bcos.sdk.channel.model.Options;
import org.fisco.bcos.sdk.client.exceptions.ClientException;
import org.fisco.bcos.sdk.client.protocol.request.JsonRpcRequest;
import org.fisco.bcos.sdk.client.protocol.response.JsonRpcResponse;
import org.fisco.bcos.sdk.model.JsonRpcRequest;
import org.fisco.bcos.sdk.model.Message;
import org.fisco.bcos.sdk.model.MsgType;
import org.fisco.bcos.sdk.model.Response;
Expand Down
Loading