forked from community/device-mgt-plugins
parent
808b0d2e5d
commit
3bad1f5747
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.extensions.remote.session.dto;
|
||||
|
||||
import org.wso2.carbon.device.mgt.extensions.remote.session.dto.common.RemoteSession;
|
||||
|
||||
import javax.websocket.Session;
|
||||
|
||||
/**
|
||||
* {@link ClientSession} is the represent of client which will be connecting to the device
|
||||
*/
|
||||
public class ClientSession extends RemoteSession {
|
||||
|
||||
|
||||
public ClientSession(Session session, String tenantDomain, String deviceType, String deviceId, String operationId) {
|
||||
super(session, tenantDomain, deviceType, deviceId, operationId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applyThrottlingPolicy() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.extensions.remote.session.dto;
|
||||
|
||||
import org.wso2.carbon.device.mgt.extensions.remote.session.dto.common.RemoteSession;
|
||||
import org.wso2.carbon.device.mgt.extensions.remote.session.internal.RemoteSessionManagementDataHolder;
|
||||
|
||||
import javax.websocket.Session;
|
||||
|
||||
/**
|
||||
* {@link DeviceSession} is the represent of device which will be connecting based on client request
|
||||
*/
|
||||
public class DeviceSession extends RemoteSession {
|
||||
|
||||
|
||||
public DeviceSession(Session session, String tenantDomain, String deviceType, String deviceId, String operationId) {
|
||||
super(session, tenantDomain, deviceType, deviceId, operationId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applyThrottlingPolicy() {
|
||||
if (RemoteSessionManagementDataHolder.getInstance().getMessagesPerSession() > 0) {
|
||||
long minDurationMessagesPerSecond = 1000 / RemoteSessionManagementDataHolder.getInstance()
|
||||
.getMessagesPerSession();
|
||||
if ((System.currentTimeMillis() - getLastMessageTimeStamp()) < minDurationMessagesPerSecond) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
35
components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/dto/common/RemoteSession.java → components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/dto/RemoteSession.java
35
components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/dto/common/RemoteSession.java → components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/dto/RemoteSession.java
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.device.mgt.extensions.remote.session.exception;
|
||||
|
||||
|
||||
import javax.websocket.CloseReason;
|
||||
|
||||
/**
|
||||
* This Exception will be thrown, when there any interference with Remote RemoteSession.
|
||||
*/
|
||||
public class RemoteSessionInvalidException extends Exception {
|
||||
|
||||
CloseReason closeReason;
|
||||
|
||||
public RemoteSessionInvalidException(String msg, CloseReason closeReason, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
this.closeReason = closeReason;
|
||||
}
|
||||
|
||||
public RemoteSessionInvalidException(String message, CloseReason closeReason, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.closeReason = closeReason;
|
||||
}
|
||||
|
||||
public RemoteSessionInvalidException(String msg, CloseReason closeReason) {
|
||||
super(msg);
|
||||
this.closeReason = closeReason;
|
||||
}
|
||||
|
||||
public CloseReason getCloseReason() {
|
||||
return closeReason;
|
||||
}
|
||||
|
||||
public void setCloseReason(CloseReason closeReason) {
|
||||
this.closeReason = closeReason;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue