void JavaCionGeneratorBase::GenMethodId(std::ofstream& stream,
const Interface& iface) {
int cnt = 2;
- stream << Tab(1) << "public static final int __RESULT = 0;" << NLine(1);
- stream << Tab(1) << "public static final int __CALLBACK = 1;" << NLine(1);
+ stream << Tab(1) << "public static final int __RESULT = 0;" << NLine(2);
+ stream << Tab(1) << "public static final int __CALLBACK = 1;" << NLine(2);
for (auto& i : iface.GetDeclarations().GetDecls()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
stream << Tab(1)
<< "public static final int __"
- << i->GetID() << " = " << cnt++ << ";" << NLine(1);
+ << i->GetID() << " = " << cnt++ << ";" << NLine(2);
}
- stream << NLine(1);
}
void JavaCionGeneratorBase::GenDeclaration(std::ofstream& stream,
if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
continue;
stream << Tab(1) << "private static final int __"
- << i->GetID() << " = " << cnt++ << ";" << NLine(1);
+ << i->GetID() << " = " << cnt++ << ";" << NLine(2);
}
- stream << NLine(1);
}
void JavaCionGeneratorBase::GenShareFile(std::ofstream& stream,
const char DEFAULT_PROXY_REPO[] =
R"__java_cb(
-
import android.content.Context;
-import androidx.lifecycle.MutableLiveData;
import org.tizen.cion.*;
import java.net.SocketTimeoutException;
-import java.util.ArrayList;
+/**
+ * Abstract class for making a client
+ */
public abstract class ClientBase implements DiscoveryCallback,
ClientConnectionLifecycleCallback, PayloadAsyncResultCallback {
- private ClientChannel client;
- private Context context;
-
- public ClientBase(Context context, String serviceName) {
- client = new ClientChannel(context, serviceName);
- this.context = context;
- }
-
- public ClientBase(Context context, String serviceName, SecurityInfo sec) {
- client = new ClientChannel(context, serviceName, sec);
- this.context = context;
- }
-
+ private ClientChannel mClient;
+
+ private Context mContext;
+
+ /**
+ * Constructor
+ * @param mContext The Context
+ * @param serviceName Service name
+ */
+ public ClientBase(Context mContext, String serviceName) {
+ mClient = new ClientChannel(mContext, serviceName);
+ this.mContext = mContext;
+ }
+
+ /**
+ * Constructor with security information
+ * @param mContext The context
+ * @param serviceName Service name
+ * @param sec Security information
+ */
+ public ClientBase(Context mContext, String serviceName, SecurityInfo sec) {
+ mClient = new ClientChannel(mContext, serviceName, sec);
+ this.mContext = mContext;
+ }
+
+ /**
+ * Disconnects server
+ */
public void disconnect() {
- client.disconnect();
+ mClient.disconnect();
}
+ /**
+ * Connects the server
+ * @param peer Server information
+ */
public void tryConnect(PeerInfo peer) {
- client.tryConnect(peer, this);
+ mClient.tryConnect(peer, this);
}
+ /**
+ * Finds available servers
+ */
public void tryDiscovery() {
- client.tryDiscovery(this);
+ mClient.tryDiscovery(this);
+ }
+
+ /**
+ * Stops finding servers
+ */
+ public void stopDiscovery() {
+ mClient.stopDiscovery();
}
+ /**
+ * Sends data payload asynchronously to the connected server
+ * @param payload Data payload
+ */
public void sendAsync(DataPayload payload) {
- client.sendPayloadAsync(payload, this);
+ mClient.sendPayloadAsync(payload, this);
}
+ /**
+ * Sends file payload asynchronously to the connected server
+ * @param payload File payload
+ */
public void sendAsync(FilePayload payload) {
- client.sendPayloadAsync(payload, this);
+ mClient.sendPayloadAsync(payload, this);
}
+ /**
+ * Sends data synchronously to the connected server
+ * @param data Data to send
+ * @return Received data
+ */
public byte[] sendData(byte[] data) {
try {
- return client.sendData(data, 5000);
+ return mClient.sendData(data, 5000);
} catch (SocketTimeoutException e) {
e.printStackTrace();
}
return null;
}
+
+ @Override
+ public final void onLost(PeerInfo peerInfo) {
+ }
}
)__java_cb";
R"__java_cb(
import android.content.Context;
-import androidx.lifecycle.LiveData;
-import androidx.lifecycle.MutableLiveData;
-
import org.tizen.cion.*;
-import java.util.ArrayList;
-import java.util.concurrent.BlockingDeque;
-import java.util.concurrent.TimeUnit;
-
-public abstract class ServerBase implements ServerConnectionLifecycleCallback {
- private ServerChannel server;
- private Context context;
- private String serviceName;
- private String displayName;
-
- public ServerBase(Context context, String serviceName, String displayName) {
- server = new ServerChannel(context, serviceName, displayName);
- this.context = context;
- this.serviceName = serviceName;
- this.displayName = displayName;
- }
-
- public ServerBase(Context context, String serviceName, String displayName, SecurityInfo sec) {
- server = new ServerChannel(context, serviceName, displayName, sec);
- this.context = context;
- this.serviceName = serviceName;
- this.displayName = displayName;
- }
-
+/**
+ * Abstract class for making a server
+ */
+public abstract class ServerBase implements ServerConnectionLifecycleCallback,
+ PayloadAsyncResultCallback {
+ private ServerChannel mServer;
+
+ private Context mContext;
+
+ private String mServiceName;
+
+ private String mDisplayName;
+
+ /**
+ * Constructor
+ * @param mContext Context
+ * @param mServiceName Service name
+ * @param mDisplayName Display name
+ */
+ public ServerBase(Context mContext, String mServiceName, String mDisplayName) {
+ mServer = new ServerChannel(mContext, mServiceName, mDisplayName);
+ this.mContext = mContext;
+ this.mServiceName = mServiceName;
+ this.mDisplayName = mDisplayName;
+ }
+
+ /**
+ * Constructor with security information
+ * @param mContext Context
+ * @param mServiceName Service name
+ * @param mDisplayName Display name
+ * @param sec Security information
+ */
+ public ServerBase(Context mContext, String mServiceName, String mDisplayName, SecurityInfo sec) {
+ mServer = new ServerChannel(mContext, mServiceName, mDisplayName, sec);
+ this.mContext = mContext;
+ this.mServiceName = mServiceName;
+ this.mDisplayName = mDisplayName;
+ }
+
+ /**
+ * Gets service name
+ * @return Service name
+ */
public String getServiceName() {
- return serviceName;
+ return mServiceName;
}
+ /**
+ * Gets display name
+ * @return Display name
+ */
public String getDisplayName() {
- return displayName;
+ return mDisplayName;
}
+ /**
+ * Waits clients
+ */
public void listen() {
- server.listen(this);
+ mServer.listen(this);
}
+ /**
+ * Stops waiting clients
+ */
public void stop() {
- server.stop();
+ mServer.stop();
}
+ /**
+ * Disconnects the connected client
+ * @param peerInfo Client information
+ */
public void disconnect(PeerInfo peerInfo) {
- server.disconnect(peerInfo);
- }
-
- public void sendPayloadAsync(IPayload payload) {
+ mServer.disconnect(peerInfo);
}
+ /**
+ * Accepts the client
+ * @param peerInfo Client information
+ */
public void accept(PeerInfo peerInfo) {
- server.acceptRequest(peerInfo);
+ mServer.acceptRequest(peerInfo);
}
+ /**
+ * Rejects the client
+ * @param peerInfo Client information
+ * @param reason The reason for rejecting the client
+ */
public void reject(PeerInfo peerInfo, String reason) {
- server.rejectRequest(peerInfo, reason);
+ mServer.rejectRequest(peerInfo, reason);
+ }
+
+ /**
+ * Sends data asynchronously to the all connected clients
+ * @param payload Data
+ */
+ public void sendPayloadAsync(IPayload payload) {
+ mServer.sendPayloadAsync(payload, this);
}
}
import org.tizen.cion.CionParcel;
+/**
+ * Abstract class for making delegator
+ */
public abstract class DelegatorBase {
- private int id;
- private int seqId;
- private boolean once;
- private static int _seqNum = 0;
+ private int mId;
+
+ private int mSeqId;
+
+ private boolean mOnce;
+
+ private static int sSeqNum = 0;
+
<DELEGATOR_IDS>
+ /**
+ * Constructor
+ * @param delegateId Delegate ID
+ * @param once Use only once
+ */
public DelegatorBase(int delegateId, boolean once) {
- this.id = delegateId;
- this.seqId = _seqNum++;
- this.once = once;
+ this.mId = delegateId;
+ this.mSeqId = sSeqNum++;
+ this.mOnce = once;
}
+
+ /**
+ * This method will be invoked when the remote callback is called
+ * @param parcel Data
+ */
public abstract void onInvoked(CionParcel parcel);
+ /**
+ * Gets sequence ID
+ * @return Sequence ID
+ */
public int getDelegateId() {
- return id;
+ return mId;
}
+ /**
+ * Gets sequence ID
+ * @return Sequence ID
+ */
public int getSequenceId() {
- return seqId;
+ return mSeqId;
}
+ /**
+ * Gets once flag
+ * @return Once flag
+ */
public boolean isOnce() {
- return once;
+ return mOnce;
}
public static void serialize(CionParcel h, DelegatorBase from) {
- h.write(from.id);
- h.write(from.seqId);
- h.write(from.once);
+ h.write(from.mId);
+ h.write(from.mSeqId);
+ h.write(from.mOnce);
}
public static void deserialize(CionParcel h, DelegatorBase to) {
- to.id = h.readInt();
- to.seqId = h.readInt();
- to.once = h.readBoolean();
+ to.mId = h.readInt();
+ to.mSeqId = h.readInt();
+ to.mOnce = h.readBoolean();
}
+ /**
+ * Gets once flag
+ * @return Once flag
+ */
public String getTag() {
- return (new Integer(id).toString()) + "_" + (new Integer(seqId).toString());
+ return (new Integer(mId).toString()) + "_" + (new Integer(mSeqId).toString());
}
}
const char CB_CALLBACK_CLASS_PROXY[] =
R"__java_cb(
- public static final class <CLS_NAME> extends DelegatorBase {
+ public static class <CLS_NAME> extends DelegatorBase {
+ /**
+ * Constructor
+ */
public <CLS_NAME>(boolean once) {
super(DelegatorBase.<IFACE_NAME>_<DELEGATOR_NAME>__, once);
}
+ /**
+ * Constructor
+ */
public <CLS_NAME>() {
super(DelegatorBase.<IFACE_NAME>_<DELEGATOR_NAME>__, false);
}
@Override
- public void onInvoked(CionParcel parcel) {
+ public final void onInvoked(CionParcel parcel) {
<METHOD_ON_INVOKED>
}
+ /**
+ * This method will be invoked when remote callback is called
+ */
public void onInvoked(<CALLBACK_PARAMS>) {}
}
)__java_cb";
const char CB_CALLBACK_CLASS_STUB[] =
R"__java_cb(
public static final class <CLS_NAME> extends DelegatorBase {
- private PeerInfo peerInfo;
- private WeakReference<ServiceBase> service;
- private boolean valid = true;
- private <IFACE_NAME> serverBase;
+ private PeerInfo mPeerInfo;
+
+ private WeakReference<ServiceBase> mService;
+
+ private boolean mValid = true;
+
+ private <IFACE_NAME> mServerBase;
public <CLS_NAME>(PeerInfo info, WeakReference<ServiceBase> service) {
super(DelegatorBase.<IFACE_NAME>_<DELEGATOR_NAME>__, false);
- this.peerInfo = info;
- this.service = service;
- this.serverBase = (<IFACE_NAME>) service.get().serverBase;
+ this.mPeerInfo = info;
+ this.mService = service;
+ this.mServerBase = (<IFACE_NAME>) service.get().mServerBase;
}
@Override
- public void onInvoked(CionParcel parcel) {}
+ public final void onInvoked(CionParcel parcel) {}
+ /**
+ * Invokes a remote callback
+ */
public void Invoke(<CALLBACK_PARAMS>) {
- if (service.get() == null)
+ if (mService.get() == null)
throw new InvalidProtocolException();
- if (isOnce() && !valid)
+ if (isOnce() && !mValid)
throw new InvalidCallbackException();
CionParcel p = new CionParcel();
<SERIALIZE>
// Send
DataPayload dp = new DataPayload(p.toByteArray());
- serverBase.sendPayloadAsync(dp);
- valid = false;
+ mServerBase.sendPayloadAsync(dp);
+ mValid = false;
<SHARE_FILE>
}
}
id += ".get()";
m += ConvertTypeToSerializer(pt.GetBaseType(), id, "p");
if (IsDelegateType(pt.GetBaseType())) {
- l += "_delegateList.add(" + id + ");\n";
+ l += "mDelegateList.add(" + id + ");\n";
}
}
st += AddIndent(TAB_SIZE * 2, m) + NLine(1);
- st += Tab(2) + "synchronized (_lock) {" + NLine(1);
+ st += Tab(2) + "synchronized (mLock) {" + NLine(1);
if (!l.empty())
- st += AddIndent(TAB_SIZE * 2, l) + NLine(1);
+ st += AddIndent(TAB_SIZE * 3, l) + NLine(1);
// Deserialize
if (decl.GetMethodType() == Declaration::MethodType::ASYNC) {
c += i->GetID() + ".set(" + i->GetID() + "_raw);" + NLine(1);
if (c != "")
- st += AddIndent(TAB_SIZE * 2, c);
+ st += AddIndent(TAB_SIZE * 3, c);
}
if (decl.GetType().ToString() != "void") {
- st += AddIndent(TAB_SIZE * 2, ConvertTypeToDeserializer(decl.GetType(),
+ st += AddIndent(TAB_SIZE * 3, ConvertTypeToDeserializer(decl.GetType(),
"ret", "parcelReceived"));
}
- st += NLine(1) + Tab(2) + "return ret;" + NLine(1);
+ st += NLine(1) + Tab(3) + "return ret;" + NLine(1);
st += Tab(2) + "}";
return st;
const char CB_DATA_MEMBERS[] =
R"__java_cb(
public String serviceName;
- private static final String _tidlVersion = "<VERSION>";
- private boolean _online = false;
- private Object _lock = new Object();
- private List<DelegatorBase> _delegateList = new LinkedList<DelegatorBase>();
+
+ private static final String sTidlVersion = "<VERSION>";
+
+ private boolean mOnline = false;
+
+ private Object mLock = new Object();
+
+ private List<DelegatorBase> mDelegateList = new LinkedList<DelegatorBase>();
)__java_cb";
const char CB_EVENT_METHODS[] =
int seqId = parcel.readInt();
boolean once = parcel.readBoolean();
- for (DelegatorBase i : _delegateList) {
+ for (DelegatorBase i : mDelegateList) {
if (i.getDelegateId() == id && i.getSequenceId() == seqId) {
i.onInvoked(parcel);
if (i.isOnce())
- _delegateList.remove(i);
+ mDelegateList.remove(i);
break;
}
}
}
+ /**
+ * This method will be invoked when this client gets the response from the server
+ * @param peerInfo Server information
+ * @param result Connection result
+ */
@Override
public void onConnectionResult(PeerInfo peerInfo, ConnectionResult result) {
if (result.status == ConnectionResult.ConnectionStatus.CONNECTION_OK) {
- _online = true;
+ mOnline = true;
}
}
+ /**
+ * This method will be invoked when this client is disconnected from the server
+ * @param peerInfo Server information
+ */
@Override
public void onDisconnected(PeerInfo peerInfo) {
- _online = false;
+ mOnline = false;
}
+ /**
+ * This method will be invoked when an available server is discovered
+ * @param peerInfo Server information
+ */
@Override
public void onDiscovered(PeerInfo peerInfo) {
}
@Override
- public void onLost(PeerInfo peerInfo) {
- }
-
- @Override
- public void onResultReceived(PayloadAsyncResult payloadAsyncResult) {
+ public final void onResultReceived(PayloadAsyncResult payloadAsyncResult) {
}
@Override
- public void onPayloadReceived(IPayload payload, PayloadTransferStatus status) {
+ public final void onPayloadReceived(IPayload payload, PayloadTransferStatus status) {
if(payload.getType() == IPayload.PayloadType.PAYLOAD_FILE) {
onFileReceived((FilePayload)payload, status);
} else {
}
}
+ /**
+ * This method will be invoked when data for a file is received from the server
+ * @param payload File data
+ * @param status Status
+ */
public void onFileReceived(FilePayload payload, PayloadTransferStatus status) {}
)__java_cb";
const char CB_CONNECT_METHOD[] =
R"__java_cb(
- /// <summary>
- /// Starts discovering cion servers.
- /// </summary>
- /// <exception cref="InvalidOperationException">Thrown when the discovery operation is already in progress.</exception>
- @Override
- public void tryDiscovery() {
- super.tryDiscovery();
- }
-
- /// <summary>
- /// Connects to the stub app.
- /// </summary>
- /// <param name="peer">The peer to connect.</param>
- /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
- /// <privilege>http://tizen.org/privilege/internet</privilege>
- /// <exception cref="PermissionDeniedException">
- /// Thrown when the permission is denied.
- /// </exception>
- /// <remark> If you want to use this method, you must add privileges.</remark>
- @Override
- public void tryConnect(PeerInfo peer) {
- super.tryConnect(peer);
- }
-
- /// <summary>
- /// Disconnects from the stub app.
- /// </summary>
- @Override
- public void disconnect() {
- super.disconnect();
- }
-
- /// <summary>
- /// Disposes delegate objects in this interface
- /// </summary>
- /// <param name="tag">The tag string from delegate object</param>
+ /**
+ * Disposes delegate objects in this interface
+ * @param tag String handle
+ */
public void disposeCallback(String tag) {
- for (DelegatorBase i : _delegateList) {
+ for (DelegatorBase i : mDelegateList) {
if (i.getTag().equals(tag)) {
- _delegateList.remove(i);
+ mDelegateList.remove(i);
return;
}
}
)__java_cb";
const char CB_INVOCATION_PRE[] =
-R"__java_cb( if (!_online)
+R"__java_cb( if (!mOnline)
throw new NotConnectedSocketException();
CionParcel p = new CionParcel();
const char CB_SHARE_FILE[] =
R"__java_cb(
- try {
+ try {
$$
- } catch (InvalidArgumentException e) {
- }
+ } catch (InvalidArgumentException e) {
+ }
)__java_cb";
const char CB_ASYNC_INVOCATION_MID[] =
R"__java_cb(
- // Send
- DataPayload dp = new DataPayload(p.toByteArray());
- super.sendAsync(dp);
+ // Send
+ DataPayload dp = new DataPayload(p.toByteArray());
+ super.sendAsync(dp);
)__java_cb";
const char CB_SYNC_INVOCATION_MID[] =
R"__java_cb(
- // Send
- byte[] dataReceived = sendData(p.toByteArray());
+ // Send
+ byte[] dataReceived = sendData(p.toByteArray());
- CionParcel parcelReceived = new CionParcel(dataReceived);
+ CionParcel parcelReceived = new CionParcel(dataReceived);
- int cmd = parcelReceived.readInt();
- if (cmd != __RESULT)
- throw new InvalidProtocolException();
+ int cmd = parcelReceived.readInt();
+ if (cmd != __RESULT)
+ throw new InvalidProtocolException();
)__java_cb";
#endif // IDLC_JAVA_CION_GEN_JAVA_PROXY_GEN_CB_H_
stream << NLine(1);
stream << "public final class " << st.GetID() << " ";
GenBrace(stream, 0, [&]() {
- stream << NLine(1);
- for (auto& i : st.GetElements().GetElms()) {
- GenSetter(stream, *i);
- GenGetter(stream, *i);
- stream << NLine(1);
- }
-
- stream << NLine(1);
GenTemplate(variable, stream,
[&]()->std::string {
std::string str;
for (auto& i : st.GetElements().GetElms()) {
- str += NLine(1) + Tab(1);
+ str += NLine(1) + Tab(1) + "private ";
if (i->GetType().GetMetaType() == nullptr) {
str += ConvertTypeToString(i->GetType()) + " "
+ i->GetID() + "_;";
+ i->GetID() + "_ = new "
+ ConvertTypeToString(i->GetType()) + "();";
}
+ str += NLine(1);
}
- str += NLine(1);
+
return str;
});
+
+ for (auto& i : st.GetElements().GetElms()) {
+ GenSetter(stream, *i);
+ GenGetter(stream, *i);
+ stream << NLine(1);
+ }
}, false, false);
stream << NLine(1);
}
#define IDLC_JAVA_CION_GEN_JAVA_STUB_GEN_CB_H_
const char CB_DATA_MEMBERS[] =
-R"__java_cb( private List<ServiceBase> _services = new LinkedList<ServiceBase>();
- private Class<?> _serviceType;
- private static final String _tidlVersion = "<VERSION>";
+R"__java_cb( private List<ServiceBase> mServices = new LinkedList<ServiceBase>();
+
+ private Class<?> mServiceType;
+
+ private static final String sTidlVersion = "<VERSION>";
+
)__java_cb";
const char CB_SERVICE_BASE_FRONT[] =
R"__java_cb(
+ /**
+ * Abstract class for making a service
+ */
public abstract class ServiceBase {
- String serviceName;
- String displayName;
- PeerInfo client;
- PeerInfo connectionRequestClient;
- ServerBase serverBase;
-
- /// <summary>
- /// The name of service
- /// </summary>
- public String getServiceName() {
- return serviceName;
+ private String mServiceName;
+
+ private String mDisplayName;
+
+ private PeerInfo mClient;
+
+ private PeerInfo mConnectionRequestClient;
+
+ private ServerBase mServerBase;
+
+ /**
+ * Gets service name
+ * @return Service name
+ */
+ public String getmServiceName() {
+ return mServiceName;
}
- /// <summary>
- /// The display name of service
- /// </summary>
- public String getDisplayName() {
- return displayName;
+ /**
+ * Gets display name
+ * @return Display name
+ */
+ public String getmDisplayName() {
+ return mDisplayName;
}
- /// <summary>
- /// The PeerInfo of client
- /// </summary>
- public PeerInfo getClient() {
- return client;
+ /**
+ * Gets client information
+ * @return Client information
+ */
+ public PeerInfo getmClient() {
+ return mClient;
}
protected ServiceBase() {}
- /// <summary>
- /// Disconnects from the client app
- /// </summary>
- /// <exception cref="System.InvalidOperationException">
- /// Thrown when an internal IO error occurrs.
- /// </exception>
+ /**
+ * Disconnects from the client app
+ */
public void disconnect() {
- if (client != null)
- serverBase.disconnect(client);
+ if (mClient != null)
+ mServerBase.disconnect(mClient);
}
- /// <summary>
- /// Accepts the connection request from the client.
- /// </summary>
+ /**
+ * Accepts the connection request from the client
+ */
public void accept() {
- if (connectionRequestClient != null)
- serverBase.accept(connectionRequestClient);
+ if (mConnectionRequestClient != null)
+ mServerBase.accept(mConnectionRequestClient);
}
- /// <summary>
- /// Rejects the connection request from the client.
- /// </summary>
- /// <param name="reason">The reason why reject the connection request.</param>
+ /**
+ * Rejects the connection request from the client
+ * @param reason The season
+ */
public void reject(String reason) {
- if (connectionRequestClient != null)
- serverBase.reject(connectionRequestClient, reason);
+ if (mConnectionRequestClient != null)
+ mServerBase.reject(mConnectionRequestClient, reason);
}
- /// <summary>
- /// This method will be called when connection requested from the client
- /// </summary>
+ /**
+ * This method will be called when connection requested from the client
+ */
public abstract void onConnectionRequest();
- /// <summary>
- /// This method will be called when received file payload.
- /// </summary>
+ /**
+ * This method will be called when received file payload
+ * @param file File information
+ * @param status The status
+ */
public abstract void onFilePayloadReceived(FilePayload file, PayloadTransferStatus status);
- /// <summary>
- /// This method will be called when the client is disconnected
- /// </summary>
+ /**
+ * This method will be called when the client is disconnected
+ */
public abstract void onTerminate();
- /// <summary>
- /// This method will be called when the client is connected
- /// </summary>
+ /**
+ * This method will be called when the client is connected
+ */
public abstract void onConnected();
)__java_cb";
const char CB_ON_RECEIVED_ASYNC_EVENT_FRONT[] =
R"__java_cb(
@Override
- public void onPayloadReceived(PeerInfo info, IPayload data, PayloadTransferStatus status) {
+ public final void onPayloadReceived(PeerInfo info, IPayload data, PayloadTransferStatus status) {
try {
CionParcel p;
ServiceBase b = null;
- for (ServiceBase i : _services) {
- if (i.client == null)
+ for (ServiceBase i : mServices) {
+ if (i.mClient == null)
continue;
- if (i.client.getAppId().equals(info.getAppId()) &&
- i.client.getUuid().equals(info.getUuid())) {
+ if (i.mClient.getAppId().equals(info.getAppId()) &&
+ i.mClient.getUuid().equals(info.getUuid())) {
b = i;
break;
}
const char CB_ON_RECEIVED_SYNC_EVENT_FRONT[] =
R"__java_cb(
@Override
- public byte[] onDataReceived(PeerInfo info, byte[] data) {
+ public final byte[] onDataReceived(PeerInfo info, byte[] data) {
CionParcel p;
byte[] returnData = new byte[0];
try {
ServiceBase b = null;
- for (ServiceBase i : _services) {
- if (i.client == null)
+ for (ServiceBase i : mServices) {
+ if (i.mClient == null)
continue;
- if (i.client.getAppId().equals(info.getAppId()) &&
- i.client.getUuid().equals(info.getUuid())) {
+ if (i.mClient.getAppId().equals(info.getAppId()) &&
+ i.mClient.getUuid().equals(info.getUuid())) {
b = i;
break;
}
public void onConnectionRequest(PeerInfo peerInfo) {
ServiceBase s;
try {
- final Object o = _serviceType.newInstance();
+ final Object o = mServiceType.newInstance();
s = (ServiceBase) o;
} catch (Exception e) {
return;
}
- s.serviceName = getServiceName();
- s.displayName = getDisplayName();
- s.connectionRequestClient = peerInfo;
- s.serverBase = this;
+ s.mServiceName = getServiceName();
+ s.mDisplayName = getDisplayName();
+ s.mConnectionRequestClient = peerInfo;
+ s.mServerBase = this;
s.onConnectionRequest();
- _services.add(s);
+ mServices.add(s);
}
)__java_cb";
R"__java_cb(
@Override
public void onConnectionResult(PeerInfo peerInfo, ConnectionResult result) {
- for (ServiceBase i : _services) {
- if (i.connectionRequestClient == null)
+ for (ServiceBase i : mServices) {
+ if (i.mConnectionRequestClient == null)
continue;
- if (i.connectionRequestClient.getAppId().equals(peerInfo.getAppId()) &&
- i.connectionRequestClient.getUuid().equals(peerInfo.getUuid())) {
+ if (i.mConnectionRequestClient.getAppId().equals(peerInfo.getAppId()) &&
+ i.mConnectionRequestClient.getUuid().equals(peerInfo.getUuid())) {
if (result.status == ConnectionResult.ConnectionStatus.CONNECTION_OK) {
- i.client = i.connectionRequestClient;
- i.connectionRequestClient = null;
+ i.mClient = i.mConnectionRequestClient;
+ i.mConnectionRequestClient = null;
i.onConnected();
} else {
- _services.remove(i);
+ mServices.remove(i);
}
break;
}
R"__java_cb(
@Override
public void onDisconnected(PeerInfo peerInfo) {
- for (ServiceBase i : _services) {
- if (i.client == null)
+ for (ServiceBase i : mServices) {
+ if (i.mClient == null)
continue;
- if (i.client.getAppId().equals(peerInfo.getAppId()) &&
- i.client.getUuid().equals(peerInfo.getUuid())) {
+ if (i.mClient.getAppId().equals(peerInfo.getAppId()) &&
+ i.mClient.getUuid().equals(peerInfo.getUuid())) {
i.onTerminate();
- _services.remove(i);
+ mServices.remove(i);
break;
}
}
const char CB_COMMON_METHODS[] =
R"__java_cb(
- /// <summary>
- /// Listens to client apps
- /// </summary>
- /// <param name="serviceType">The type object for making service instances</param>
- /// <exception cref="InvalidIOException">
- /// Thrown when internal I/O error happen.
- /// </exception>
- /// <exception cref="ArgumentException">
- /// Thrown when serviceType is invalid.
- /// </exception>
- /// <exception cref="InvalidOperationException">
- /// Thrown when the listen operation is already in progress.
- /// </exception>
- /// <exception cref="UnauthorizedAccessException">
- /// Thrown when an application does not have the privilege to access this method.
- /// </exception>
- /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
- /// <privilege>http://tizen.org/privilege/internet</privilege>
+ @Override
+ public final void onResultReceived(PayloadAsyncResult payloadAsyncResult) {
+ }
+
+ /**
+ * Waits clients
+ * @param serviceType Service class type
+ */
public void listen(Class<?> serviceType) {
- _serviceType = serviceType;
+ mServiceType = serviceType;
super.listen();
}
- /// <summary>
- /// Stops the listen operation.
- /// </summary>
- /// <exception cref="InvalidOperationException">Thrown when the server is not listening.</exception>
+ /**
+ * Stops the listen operation
+ */
+ @Override
public void stop() {
super.stop();
- _services.clear();
+ mServices.clear();
}
- /// <summary>
- /// Gets service objects which are connected
- /// </summary>
- /// <returns>The enumerable service objects which are connected</returns>
+ /**
+ * Gets service objects which are connected
+ * @return Service objects which are connected
+ */
public List<ServiceBase> getServices() {
- return _services;
+ return mServices;
}
+
)__java_cb";