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})
--- /dev/null
+/*
+ * 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<char> message) {
+
+}
+
+void BroadcastChannel::OnDataEvent(IDataInfo info, std::vector<char> data) {
+
+}
+
+void BroadcastChannel::OnConnectionEvent(IConnectionInfo info, std::vector<char> serialized_peerInfo) {
+
+}
+
+std::string BroadcastChannel::GetServiceName() {
+ return "";
+}
+
+std::string BroadcastChannel::GetUUID() {
+ return "";
+}
+
+} //namespace cion_channel
--- /dev/null
+/*
+ * 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 <string>
+#include <vector>
+
+#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<char> message);
+
+protected:
+ virtual void OnMessageReceived(std::string data, PeerInfo peer) = 0;
+ void OnDataEvent(IDataInfo info,
+ std::vector<char> serialized_payload) override;
+ void OnConnectionEvent(IConnectionInfo info,
+ std::vector<char> serialized_peerinfo) override;
+ std::string GetServiceName() override;
+ std::string GetUUID() override;
+
+private:
+ IEventSender* sender_;
+ IEventListener* listener_;
+};
+
+} //namespace cion_channel
+
+#endif //__CION_BROADCASTCHANNEL_H__
--- /dev/null
+/*
+ * 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<char> ClientChannel::SendData(std::vector<char> data, int timeout) {
+ return {};
+}
+
+void ClientChannel::SendPayLoadAsync(IPayLoad data) {
+
+}
+
+std::unique_ptr<PeerInfo> ClientChannel::GetPeerInfo() {
+ return {};
+}
+
+void ClientChannel::OnDataEvent(IDataInfo info, std::vector<char> data) {
+
+}
+
+void ClientChannel::OnConnectionEvent(IConnectionInfo info,
+ std::vector<char> serialized_peerInfo) {
+
+}
+
+std::string ClientChannel::GetServiceName() {
+ return "";
+}
+
+std::string ClientChannel::GetUUID() {
+ return "";
+}
+
+} //namespace cion_channel
--- /dev/null
+/*
+ * 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 <string>
+#include <memory>
+#include <vector>
+
+#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<char> SendData(std::vector<char> data, int timeout);
+ void SendPayLoadAsync(IPayLoad data);
+ std::unique_ptr<PeerInfo> GetPeerInfo();
+ void SetSecurity(SecurityInfo sec);
+
+protected:
+ virtual void OnConnentionStatusChaneged(PeerInfo peer,
+ ConnectionStatus status) = 0;
+ virtual std::vector<char> OnDataReceived(std::vector<char> 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<char> serialized_payload) override;
+ void OnConnectionEvent(IConnectionInfo info,
+ std::vector<char> serialized_peerinfo) override;
+ std::string GetServiceName() override;
+ std::string GetUUID() override;
+
+private:
+ IEventSender* sender_;
+ IEventListener* listener_;
+};
+
+} //namespace cion_channel
+
+#endif //__CION_CLIENTCHANNEL_H__
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 <string>
+
+namespace cion_channel {
+
+enum class ConnectionStatus {
+ ONLINE,
+ OFFLINE,
+};
+
+class IConnectionInfo {
+ public:
+ int GetConnectionType();
+ std::string GetUUID();
+};
+
+} //namespace cion_channel
+
+#endif //__CION_ICONNECTIONINFO_H__
--- /dev/null
+
+/*
+ * 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
--- /dev/null
+
+/*
+ * 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__
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 <string>
+
+namespace cion_channel {
+
+class IDataInfo {
+ public:
+ int GetType();
+ std::string GetUUID();
+};
+
+} //namespace cion_channel
+
+#endif //_IDATAINFO_H
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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__
--- /dev/null
+
+/*
+ * 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 <string>
+#include <vector>
+
+#include "IConnectionInfo.h"
+#include "IDataInfo.h"
+
+namespace cion_channel {
+
+class IEventObserver {
+ public:
+
+ virtual void OnDataEvent(IDataInfo info,
+ std::vector<char> serialized_payload) = 0;
+
+ virtual void OnConnectionEvent(IConnectionInfo info,
+ std::vector<char> serialized_peerinfo) = 0;
+
+ virtual std::string GetServiceName() = 0;
+ virtual std::string GetUUID() = 0;
+};
+
+class IPayLoad{
+};
+
+} //namespace cion_channel
+
+#endif //__CION_IEVENTOBSERVER_H__
--- /dev/null
+/*
+ * 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<char> data, IDataInfo info) {
+
+}
+
+void IEventSender::SendData(std::vector<char> data, IDataInfo info, std::string uuid) {
+
+}
+
+int IEventSender::OperateChannel(IControlInfo info, std::string uuid) {
+ return 0;
+}
+
+} //namespace cion_channel
--- /dev/null
+/*
+ * 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 <string>
+#include <vector>
+
+#include "IDataInfo.h"
+#include "IControlInfo.h"
+#include "SecurityInfo.h"
+
+namespace cion_channel {
+
+class IEventSender {
+ public:
+ virtual void SendDataAsync(std::vector<char> data, IDataInfo info);
+ virtual void SendData(std::vector<char> 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__
--- /dev/null
+/*
+ * 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 <string>
+
+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
--- /dev/null
+
+/*
+ * 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<char> ServerChannel::SendData(std::vector<char> data, PeerInfo peer,
+ int timeout) {
+ return {};
+}
+
+void ServerChannel::SendPayLoadAsync(IPayLoad data) {
+
+}
+
+void ServerChannel::SendPayLoadAsync(IPayLoad data, PeerInfo peer) {
+
+}
+
+std::list<PeerInfo> ServerChannel::GetConnectedPeerList() {
+ return {};
+}
+
+void ServerChannel::OnDataEvent(IDataInfo info, std::vector<char> data) {
+
+}
+
+void ServerChannel::OnConnectionEvent(IConnectionInfo info, std::vector<char> serialized_peerInfo) {
+
+}
+
+std::string ServerChannel::GetServiceName() {
+ return "";
+}
+
+std::string ServerChannel::GetUUID() {
+ return "";
+}
+
+} //namespace cion_channel
--- /dev/null
+
+/*
+ * 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 <string>
+#include <vector>
+#include <list>
+
+#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<char> SendData(std::vector<char> data, PeerInfo peer, int timeout);
+ void SendPayLoadAsync(IPayLoad data);
+ void SendPayLoadAsync(IPayLoad data, PeerInfo peer);
+ std::list<PeerInfo> GetConnectedPeerList();
+ void SetSecurity(SecurityInfo sec);
+
+ protected:
+ virtual void OnConnentionStatusChaneged(PeerInfo peer,
+ ConnectionStatus status) = 0;
+ virtual std::vector<char> OnDataReceived(std::vector<char> 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<char> serialized_payload) override;
+ void OnConnectionEvent(IConnectionInfo info,
+ std::vector<char> serialized_peerinfo) override;
+ std::string GetServiceName() override;
+ std::string GetUUID() override;
+
+private:
+ IEventSender* sender_;
+ IEventListener* listener_;
+};
+
+} //namespace cion_channel
+
+#endif //__CION_SERVERCHANNEL_H__