From: Inkyun Kil Date: Fri, 8 Jan 2021 01:27:45 +0000 (+0900) Subject: Add skeleton codes for channel interface X-Git-Tag: submit/tizen/20210806.015209~97^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da99b18657b9d6a399c69d854beb2da326e7868c;p=platform%2Fcore%2Fappfw%2Fcion.git Add skeleton codes for channel interface Signed-off-by: Inkyun Kil --- diff --git a/cion/CMakeLists.txt b/cion/CMakeLists.txt index 133358f..edc0269 100644 --- a/cion/CMakeLists.txt +++ b/cion/CMakeLists.txt @@ -27,8 +27,9 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/tizen-api/) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common/ COMMON_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/channel/ CHANNEL_SOURCES) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/tizen-api/ SOURCES) -ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES} ${COMMON_SOURCES}) +ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES} ${COMMON_SOURCES} ${CHANNEL_SOURCES}) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER}) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${MAJORVER}) diff --git a/cion/channel/BroadcastChannel.cc b/cion/channel/BroadcastChannel.cc new file mode 100755 index 0000000..baaf8d3 --- /dev/null +++ b/cion/channel/BroadcastChannel.cc @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include "BroadcastChannel.h" + +/** + * BroadcastChannel implementation + */ + +namespace cion_channel { + + +BroadcastChannel::BroadcastChannel(std::string& topic, IEventSender* sender, + IEventListener* listener) : sender_(sender), listener_(listener) { + +} + +void BroadcastChannel::Subscribe() { + +} + +void BroadcastChannel::Unsubscribe() { + +} + +void BroadcastChannel::SendMessage(std::vector message) { + +} + +void BroadcastChannel::OnDataEvent(IDataInfo info, std::vector data) { + +} + +void BroadcastChannel::OnConnectionEvent(IConnectionInfo info, std::vector serialized_peerInfo) { + +} + +std::string BroadcastChannel::GetServiceName() { + return ""; +} + +std::string BroadcastChannel::GetUUID() { + return ""; +} + +} //namespace cion_channel diff --git a/cion/channel/BroadcastChannel.h b/cion/channel/BroadcastChannel.h new file mode 100755 index 0000000..597edcd --- /dev/null +++ b/cion/channel/BroadcastChannel.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CION_BROADCASTCHANNEL_H__ +#define __CION_BROADCASTCHANNEL_H__ + +#include +#include + +#include "IEventObserver.h" +#include "IEventListener.h" +#include "IEventSender.h" +#include "../common/peer_info.h" + +using namespace cion_common; + +namespace cion_channel { + +class BroadcastChannel: public IEventObserver { +public: + BroadcastChannel(std::string& topic, IEventSender* sender, + IEventListener* listener); + void Subscribe(); + void Unsubscribe(); + void SendMessage(std::vector message); + +protected: + virtual void OnMessageReceived(std::string data, PeerInfo peer) = 0; + void OnDataEvent(IDataInfo info, + std::vector serialized_payload) override; + void OnConnectionEvent(IConnectionInfo info, + std::vector serialized_peerinfo) override; + std::string GetServiceName() override; + std::string GetUUID() override; + +private: + IEventSender* sender_; + IEventListener* listener_; +}; + +} //namespace cion_channel + +#endif //__CION_BROADCASTCHANNEL_H__ diff --git a/cion/channel/ClientChannel.cc b/cion/channel/ClientChannel.cc new file mode 100755 index 0000000..cacc09c --- /dev/null +++ b/cion/channel/ClientChannel.cc @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include "ClientChannel.h" + +/** + * ClientChannel implementation + */ + +namespace cion_channel { + + +ClientChannel::ClientChannel(std::string& service_name, IEventSender* sender, + IEventListener* listener) : sender_(sender), listener_(listener) { + +} + +void ClientChannel::TryDiscovery() { + +} + +void ClientChannel::StopDiscovery() { + +} + +void ClientChannel::Connect(PeerInfo peer) { + +} + +void ClientChannel::Disconnect() { + +} + +std::vector ClientChannel::SendData(std::vector data, int timeout) { + return {}; +} + +void ClientChannel::SendPayLoadAsync(IPayLoad data) { + +} + +std::unique_ptr ClientChannel::GetPeerInfo() { + return {}; +} + +void ClientChannel::OnDataEvent(IDataInfo info, std::vector data) { + +} + +void ClientChannel::OnConnectionEvent(IConnectionInfo info, + std::vector serialized_peerInfo) { + +} + +std::string ClientChannel::GetServiceName() { + return ""; +} + +std::string ClientChannel::GetUUID() { + return ""; +} + +} //namespace cion_channel diff --git a/cion/channel/ClientChannel.h b/cion/channel/ClientChannel.h new file mode 100755 index 0000000..4f4ce1c --- /dev/null +++ b/cion/channel/ClientChannel.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CION_CLIENTCHANNEL_H__ +#define __CION_CLIENTCHANNEL_H__ + +#include +#include +#include + +#include "IEventObserver.h" +#include "IEventListener.h" +#include "IEventSender.h" +#include "SecurityInfo.h" +#include "../common/peer_info.h" + +using namespace cion_common; + +namespace cion_channel { + +class ClientChannel: public IEventObserver { +public: + ClientChannel(std::string& service_name, IEventSender* sender, + IEventListener* listener); + void TryDiscovery(); + void StopDiscovery(); + void Connect(PeerInfo peer); + void Disconnect(); + std::vector SendData(std::vector data, int timeout); + void SendPayLoadAsync(IPayLoad data); + std::unique_ptr GetPeerInfo(); + void SetSecurity(SecurityInfo sec); + +protected: + virtual void OnConnentionStatusChaneged(PeerInfo peer, + ConnectionStatus status) = 0; + virtual std::vector OnDataReceived(std::vector data) = 0; + virtual void OnPayloadReceived(IPayLoad data) = 0; + virtual void OnErrorReported(int code, PeerInfo peer) = 0; + virtual void OnDiscovered(PeerInfo peer) = 0; + + void OnDataEvent(IDataInfo info, + std::vector serialized_payload) override; + void OnConnectionEvent(IConnectionInfo info, + std::vector serialized_peerinfo) override; + std::string GetServiceName() override; + std::string GetUUID() override; + +private: + IEventSender* sender_; + IEventListener* listener_; +}; + +} //namespace cion_channel + +#endif //__CION_CLIENTCHANNEL_H__ diff --git a/cion/channel/IConnectionInfo.cc b/cion/channel/IConnectionInfo.cc new file mode 100755 index 0000000..32a9b6b --- /dev/null +++ b/cion/channel/IConnectionInfo.cc @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include "IConnectionInfo.h" + +/** + * IConnectionInfo implementation + */ + +namespace cion_channel { + +int IConnectionInfo::GetConnectionType() { + return 0; +} + +std::string IConnectionInfo::GetUUID() { + return ""; +} + +} //namespace cion_channel diff --git a/cion/channel/IConnectionInfo.h b/cion/channel/IConnectionInfo.h new file mode 100755 index 0000000..8b93385 --- /dev/null +++ b/cion/channel/IConnectionInfo.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CION_ICONNECTIONINFO_H__ +#define __CION_ICONNECTIONINFO_H__ + +#include + +namespace cion_channel { + +enum class ConnectionStatus { + ONLINE, + OFFLINE, +}; + +class IConnectionInfo { + public: + int GetConnectionType(); + std::string GetUUID(); +}; + +} //namespace cion_channel + +#endif //__CION_ICONNECTIONINFO_H__ diff --git a/cion/channel/IControlInfo.cc b/cion/channel/IControlInfo.cc new file mode 100755 index 0000000..810036c --- /dev/null +++ b/cion/channel/IControlInfo.cc @@ -0,0 +1,34 @@ + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include "IControlInfo.h" + +/** + * IControlInfo implementation + */ + +namespace cion_channel { + +int IControlInfo::GetControlType() { + return 0; +} + +int IControlInfo::GetChannelType() { + return 0; +} + +} //namespace cion_channel diff --git a/cion/channel/IControlInfo.h b/cion/channel/IControlInfo.h new file mode 100755 index 0000000..8c3dedd --- /dev/null +++ b/cion/channel/IControlInfo.h @@ -0,0 +1,31 @@ + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CION_ICONTROLINFO_H__ +#define __CION_ICONTROLINFO_H__ + +namespace cion_channel { + +class IControlInfo { + public: + int GetControlType(); + int GetChannelType(); +}; + +} //namespace cion_channel + +#endif //__CION_ICONTROLINFO_H__ diff --git a/cion/channel/IDataInfo.cc b/cion/channel/IDataInfo.cc new file mode 100755 index 0000000..22b9335 --- /dev/null +++ b/cion/channel/IDataInfo.cc @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include "IDataInfo.h" + +/** + * IDataInfo implementation + */ + +namespace cion_channel { + +int IDataInfo::GetType() { + return 0; +} + +std::string IDataInfo::GetUUID() { + return ""; +} + +} //namespace cion_channel diff --git a/cion/channel/IDataInfo.h b/cion/channel/IDataInfo.h new file mode 100755 index 0000000..1013b25 --- /dev/null +++ b/cion/channel/IDataInfo.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef _IDATAINFO_H +#define _IDATAINFO_H + +#include + +namespace cion_channel { + +class IDataInfo { + public: + int GetType(); + std::string GetUUID(); +}; + +} //namespace cion_channel + +#endif //_IDATAINFO_H diff --git a/cion/channel/IEventListener.cc b/cion/channel/IEventListener.cc new file mode 100755 index 0000000..bb5ad7a --- /dev/null +++ b/cion/channel/IEventListener.cc @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include "IEventListener.h" + + +/** + * Channel.IEventListener implementation + */ + +namespace cion_channel { + +void IEventListener::RegisteObserver(IEventObserver* observer) { + +} + + +void IEventListener::UnregisteObserver(IEventObserver* observer) { + +} + +} //namespace cion_channel diff --git a/cion/channel/IEventListener.h b/cion/channel/IEventListener.h new file mode 100755 index 0000000..2d6c63d --- /dev/null +++ b/cion/channel/IEventListener.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CION_IEVENTLISTENER_H__ +#define __CION_IEVENTLISTENER_H__ + +#include "IEventObserver.h" + +namespace cion_channel { + +class IEventListener { +public: + void RegisteObserver(IEventObserver* observer); + void UnregisteObserver(IEventObserver* observer); +}; + +} //namespace cion_channel + +#endif //__CION_IEVENTLISTENER_H__ diff --git a/cion/channel/IEventObserver.h b/cion/channel/IEventObserver.h new file mode 100755 index 0000000..fb93f32 --- /dev/null +++ b/cion/channel/IEventObserver.h @@ -0,0 +1,47 @@ + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CION_IEVENTOBSERVER_H__ +#define __CION_IEVENTOBSERVER_H__ + +#include +#include + +#include "IConnectionInfo.h" +#include "IDataInfo.h" + +namespace cion_channel { + +class IEventObserver { + public: + + virtual void OnDataEvent(IDataInfo info, + std::vector serialized_payload) = 0; + + virtual void OnConnectionEvent(IConnectionInfo info, + std::vector serialized_peerinfo) = 0; + + virtual std::string GetServiceName() = 0; + virtual std::string GetUUID() = 0; +}; + +class IPayLoad{ +}; + +} //namespace cion_channel + +#endif //__CION_IEVENTOBSERVER_H__ diff --git a/cion/channel/IEventSender.cc b/cion/channel/IEventSender.cc new file mode 100755 index 0000000..14644a6 --- /dev/null +++ b/cion/channel/IEventSender.cc @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include "IEventSender.h" + +/** + * Channel.IEventSender implementation + */ + +namespace cion_channel { + +void IEventSender::SendDataAsync(std::vector data, IDataInfo info) { + +} + +void IEventSender::SendData(std::vector data, IDataInfo info, std::string uuid) { + +} + +int IEventSender::OperateChannel(IControlInfo info, std::string uuid) { + return 0; +} + +} //namespace cion_channel diff --git a/cion/channel/IEventSender.h b/cion/channel/IEventSender.h new file mode 100755 index 0000000..679fb25 --- /dev/null +++ b/cion/channel/IEventSender.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CION_IEVENTSENDER_H__ +#define __CION_IEVENTSENDER_H__ + +#include +#include + +#include "IDataInfo.h" +#include "IControlInfo.h" +#include "SecurityInfo.h" + +namespace cion_channel { + +class IEventSender { + public: + virtual void SendDataAsync(std::vector data, IDataInfo info); + virtual void SendData(std::vector data, IDataInfo info, std::string uuid); + virtual int OperateChannel(IControlInfo info, std::string uuid); + void SetSecurity(SecurityInfo sec); +}; + +} //namespace cion_channel + + +#endif //__CION_IEVENTSENDER_H__ diff --git a/cion/channel/SecurityInfo.h b/cion/channel/SecurityInfo.h new file mode 100644 index 0000000..cb6d691 --- /dev/null +++ b/cion/channel/SecurityInfo.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef _SECURITY_INFO_H +#define _SECURITY_INFO_H + +#include + +namespace cion_channel { + +class SecurityInfo { + public: + void SetCaPath(std::string path); + void SetCertPath(std::string path); + void SetPrivatePath(std::string path); + std::string GetCaPath(); + std::string GetCertPath(); + std::string GetPrivatePath(); +}; + +} //namespace cion_channel + + +#endif //_SECURITY_INFO_H diff --git a/cion/channel/ServerChannel.cc b/cion/channel/ServerChannel.cc new file mode 100755 index 0000000..c095a6a --- /dev/null +++ b/cion/channel/ServerChannel.cc @@ -0,0 +1,76 @@ + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#include "ServerChannel.h" + +/** + * ServerChannel implementation + */ + +namespace cion_channel { + +ServerChannel::ServerChannel(std::string& service_name, IEventSender* sender, + IEventListener* listener) : sender_(sender), listener_(listener) { + +} + +void ServerChannel::Listen() { + +} + +void ServerChannel::Stop() { + +} + +void ServerChannel::Disconnect(PeerInfo peer) { + +} + +std::vector ServerChannel::SendData(std::vector data, PeerInfo peer, + int timeout) { + return {}; +} + +void ServerChannel::SendPayLoadAsync(IPayLoad data) { + +} + +void ServerChannel::SendPayLoadAsync(IPayLoad data, PeerInfo peer) { + +} + +std::list ServerChannel::GetConnectedPeerList() { + return {}; +} + +void ServerChannel::OnDataEvent(IDataInfo info, std::vector data) { + +} + +void ServerChannel::OnConnectionEvent(IConnectionInfo info, std::vector serialized_peerInfo) { + +} + +std::string ServerChannel::GetServiceName() { + return ""; +} + +std::string ServerChannel::GetUUID() { + return ""; +} + +} //namespace cion_channel diff --git a/cion/channel/ServerChannel.h b/cion/channel/ServerChannel.h new file mode 100755 index 0000000..041c682 --- /dev/null +++ b/cion/channel/ServerChannel.h @@ -0,0 +1,71 @@ + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CION_SERVERCHANNEL_H__ +#define __CION_SERVERCHANNEL_H__ + +#include +#include +#include + +#include "IEventObserver.h" +#include "IEventSender.h" +#include "IEventListener.h" +#include "SecurityInfo.h" +#include "../common/peer_info.h" + +using namespace cion_common; + +namespace cion_channel { + +class ServerChannel: public IEventObserver { + public: + ServerChannel(std::string& service_name, IEventSender* sender, + IEventListener* listener); + void Listen(); + void Stop(); + void Disconnect(PeerInfo peer); + std::vector SendData(std::vector data, PeerInfo peer, int timeout); + void SendPayLoadAsync(IPayLoad data); + void SendPayLoadAsync(IPayLoad data, PeerInfo peer); + std::list GetConnectedPeerList(); + void SetSecurity(SecurityInfo sec); + + protected: + virtual void OnConnentionStatusChaneged(PeerInfo peer, + ConnectionStatus status) = 0; + virtual std::vector OnDataReceived(std::vector data, + PeerInfo peer) = 0; + virtual void OnPayloadReceived(IPayLoad data, PeerInfo peer) = 0; + virtual bool OnConnentionRequest(PeerInfo peer) = 0; + virtual void OnErrorReported(int code, PeerInfo peer) = 0; + + void OnDataEvent(IDataInfo info, + std::vector serialized_payload) override; + void OnConnectionEvent(IConnectionInfo info, + std::vector serialized_peerinfo) override; + std::string GetServiceName() override; + std::string GetUUID() override; + +private: + IEventSender* sender_; + IEventListener* listener_; +}; + +} //namespace cion_channel + +#endif //__CION_SERVERCHANNEL_H__